From f4a5d140084abe18afc601c42b5c07b352a107ee Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Fri, 10 Feb 2012 20:55:52 +0000 Subject: [PATCH] Ajustes de performance na geração do mapa --- admin/admin.db | Bin 75776 -> 0 bytes aplicmap/dados/mundo.prj | 1 - aplicmap/dados/mundo.qix | Bin 10348 -> 0 bytes aplicmap/geral1debianv6.map | 46 ++-------------------------------------------- aplicmap/geral1fedorav6.map | 45 ++------------------------------------------- aplicmap/geral1v6.map | 46 ++-------------------------------------------- aplicmap/geral1windowsv6.map | 50 ++------------------------------------------------ classesphp/mapa_googlemaps.php | 79 ++++--------------------------------------------------------------------------- classesphp/mapa_openlayers.php | 86 ++++++++++++++++---------------------------------------------------------------------- 9 files changed, 28 insertions(+), 325 deletions(-) delete mode 100644 aplicmap/dados/mundo.prj delete mode 100644 aplicmap/dados/mundo.qix diff --git a/admin/admin.db b/admin/admin.db index 14951be..2d21b68 100644 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/aplicmap/dados/mundo.prj b/aplicmap/dados/mundo.prj deleted file mode 100644 index f36876f..0000000 --- a/aplicmap/dados/mundo.prj +++ /dev/null @@ -1 +0,0 @@ -GEOGCS["GCS_South_American_1969",DATUM["D_South_American_1969",SPHEROID["GRS_1967_Truncated",6378160.0,298.25]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] \ No newline at end of file diff --git a/aplicmap/dados/mundo.qix b/aplicmap/dados/mundo.qix deleted file mode 100644 index 57715e9..0000000 Binary files a/aplicmap/dados/mundo.qix and /dev/null differ diff --git a/aplicmap/geral1debianv6.map b/aplicmap/geral1debianv6.map index 5078346..6652828 100644 --- a/aplicmap/geral1debianv6.map +++ b/aplicmap/geral1debianv6.map @@ -167,14 +167,11 @@ MAP "cache" "sim" END NAME "zee" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS TYPE POLYGON CLASS NAME " " - COLOR 137 201 255 + OUTLINECOLOR 137 201 255 END END LAYER @@ -192,45 +189,14 @@ MAP "itembuscarapida" "LONG_NAME" END NAME "mundo" - SIZEUNITS PIXELS STATUS DEFAULT TEMPLATE "none.htm" - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON - UNITS METERS CLASS NAME "" #vazio indica que nao sera incluido o nome ao lado do simbolo STYLE COLOR 230 230 230 - SIZE 1 - SYMBOL 0 - END - END - END - LAYER - DATA "/var/www/i3geo/aplicmap/dados/mundo" - GROUP "mundo" - METADATA - "CLASSE" "NAO" - "TEMA" "NAO" - "ESCONDIDO" "SIM" - "cache" "sim" - END - NAME "mundo2" - SIZEUNITS PIXELS - STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 - TYPE LINE - UNITS METERS - CLASS - STYLE - COLOR 255 255 255 - SIZE 3 - SYMBOL "linha" + OUTLINECOLOR 255 255 255 END END END @@ -245,21 +211,13 @@ MAP "EXTENSAO" "-97.911949 -39.413578 -8.185829 9.511159" END NAME "estados" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON UNITS METERS CLASS NAME " " STYLE COLOR 232 220 201 - MAXSIZE 100 - MINSIZE 1 - SIZE 1 - SYMBOL 0 END END END diff --git a/aplicmap/geral1fedorav6.map b/aplicmap/geral1fedorav6.map index 9288c98..98a2cfa 100644 --- a/aplicmap/geral1fedorav6.map +++ b/aplicmap/geral1fedorav6.map @@ -167,14 +167,11 @@ MAP "cache" "sim" END NAME "zee" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS TYPE POLYGON CLASS NAME " " - COLOR 137 201 255 + OUTLINECOLOR 137 201 255 END END LAYER @@ -192,44 +189,15 @@ MAP "itembuscarapida" "LONG_NAME" END NAME "mundo" - SIZEUNITS PIXELS STATUS DEFAULT TEMPLATE "none.htm" - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON UNITS METERS CLASS NAME "" #vazio indica que nao sera incluido o nome ao lado do simbolo STYLE COLOR 230 230 230 - SIZE 1 - SYMBOL 0 - END - END - END - LAYER - DATA "/var/www/html/i3geo/aplicmap/dados/mundo" - GROUP "mundo" - METADATA - "CLASSE" "NAO" - "TEMA" "NAO" - "ESCONDIDO" "SIM" - "cache" "sim" - END - NAME "mundo2" - SIZEUNITS PIXELS - STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 - TYPE LINE - UNITS METERS - CLASS - STYLE - COLOR 255 255 255 - WIDTH 3 + OUTLINECOLOR 255 255 255 END END END @@ -244,21 +212,12 @@ MAP "EXTENSAO" "-97.911949 -39.413578 -8.185829 9.511159" END NAME "estados" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON - UNITS METERS CLASS NAME " " STYLE COLOR 232 220 201 - MAXSIZE 100 - MINSIZE 1 - SIZE 1 - SYMBOL 0 END END END diff --git a/aplicmap/geral1v6.map b/aplicmap/geral1v6.map index f804806..d7b4603 100644 --- a/aplicmap/geral1v6.map +++ b/aplicmap/geral1v6.map @@ -162,14 +162,11 @@ MAP "cache" "sim" END NAME "zee" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS TYPE POLYGON CLASS NAME " " - COLOR 137 201 255 + OUTLINECOLOR 137 201 255 END END LAYER @@ -187,44 +184,14 @@ MAP "itembuscarapida" "LONG_NAME" END NAME "mundo" - SIZEUNITS PIXELS STATUS DEFAULT TEMPLATE "none.htm" - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON - UNITS METERS CLASS NAME "" #vazio indica que nao sera incluido o nome ao lado do simbolo STYLE COLOR 230 230 230 - SIZE 1 - SYMBOL 0 - END - END - END - LAYER - DATA "/opt/www/html/i3geo/aplicmap/dados/mundo" - GROUP "mundo" - METADATA - "CLASSE" "NAO" - "TEMA" "NAO" - "ESCONDIDO" "SIM" - "cache" "sim" - END - NAME "mundo2" - SIZEUNITS PIXELS - STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 - TYPE LINE - UNITS METERS - CLASS - STYLE - COLOR 255 255 255 - WIDTH 3 + OUTLINECOLOR 255 255 255 END END END @@ -239,21 +206,13 @@ MAP "EXTENSAO" "-97.911949 -39.413578 -8.185829 9.511159" END NAME "estados" - SIZEUNITS PIXELS STATUS DEFAULT TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON - UNITS METERS CLASS NAME " " STYLE COLOR 232 220 201 - MAXSIZE 100 - MINSIZE 1 - SIZE 1 - SYMBOL 0 END END END @@ -336,7 +295,6 @@ MAP "TEMA" "Rosa dos ventos" "IDENTIFICA" "nao" "TABELA" "nao" - END NAME "rosadosventos" SIZEUNITS PIXELS diff --git a/aplicmap/geral1windowsv6.map b/aplicmap/geral1windowsv6.map index 3d950ad..8bf5922 100644 --- a/aplicmap/geral1windowsv6.map +++ b/aplicmap/geral1windowsv6.map @@ -163,20 +163,15 @@ MAP #"MENSAGEM" "Isto é um teste de mensagem" END NAME "zee" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS TYPE POLYGON CLASS NAME " " - COLOR 137 201 255 + OUTLINECOLOR 137 201 255 END END - LAYER DATA "c:\ms4w\apache\htdocs\i3geo/aplicmap/dados/mundo" - GROUP "mundo" METADATA "CLASSE" "SIM" #o simbolo sera mostrado na legenda "ITENS" "FIPS_CNTRY,GMI_CNTRY,LONG_NAME,CNTRY_NAME" #itens que serao mostrados na opcao de identificacao @@ -190,50 +185,18 @@ MAP "itembuscarapida" "LONG_NAME" END NAME "mundo" - SIZEUNITS PIXELS STATUS DEFAULT TEMPLATE "none.htm" - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON - UNITS METERS CLASS NAME " " #vazio indica que nao sera incluido o nome ao lado do simbolo STYLE COLOR 230 230 230 - SIZE 1 - SYMBOL 0 + OUTLINECOLOR 255 255 255 END END END LAYER - DATA "c:\ms4w\apache\htdocs\i3geo/aplicmap/dados/mundo" - GROUP "mundo" - METADATA - "CLASSE" "NAO" - "TEMA" "linha" - "TEMA" "NAO" - "ESCONDIDO" "SIM" - "cache" "sim" - END - NAME "mundo2" - SIZEUNITS PIXELS - STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 - TYPE LINE - UNITS METERS - CLASS - STYLE - COLOR 255 255 255 - WIDTH 3 - END - END - END - - LAYER DATA "c:\ms4w\apache\htdocs\i3geo/aplicmap/dados/estados" METADATA "CLASSE" "SIM" @@ -245,21 +208,12 @@ MAP "cache" "sim" END NAME "estados" - SIZEUNITS PIXELS STATUS DEFAULT - TOLERANCE 0 - TOLERANCEUNITS PIXELS - TRANSPARENCY 100 TYPE POLYGON - UNITS METERS CLASS NAME " " STYLE COLOR 232 220 201 - MAXSIZE 100 - MINSIZE 1 - SIZE 1 - SYMBOL 0 END END END diff --git a/classesphp/mapa_googlemaps.php b/classesphp/mapa_googlemaps.php index 27f1e7a..94e7ebf 100644 --- a/classesphp/mapa_googlemaps.php +++ b/classesphp/mapa_googlemaps.php @@ -294,33 +294,10 @@ else{ $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; $img->saveImage($nomer); } - ob_start(); - // assuming you have image data in $imagedata - $img = file_get_contents($nomer); - $length = strlen($img); - $ft = filemtime($nomer); - if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { - // Client's cache IS current, so we just respond '304 Not Modified'. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); - } else { - // Image not cached or cache outdated, we respond '200 OK' and output the image. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); - } - header('Accept-Ranges: bytes'); - header('Content-Length: '.$length); + header('Content-Length: '.filesize($nomer)); header('Content-Type: image/png'); - print($img); - ob_end_flush(); + fpassthru(fopen($nomer, 'rb')); exit; - /* - ob_clean(); - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - */ } function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ global $img,$map_size; @@ -352,59 +329,11 @@ function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ {$nome = $cachedir."/googlemaps/".$layer."/".$nome;} if(file_exists($nome)) { - ob_start(); - // assuming you have image data in $imagedata - $img = file_get_contents($nome); - $length = strlen($img); - $ft = filemtime($nome); - if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { - // Client's cache IS current, so we just respond '304 Not Modified'. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); - } else { - // Image not cached or cache outdated, we respond '200 OK' and output the image. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); - } - header('Accept-Ranges: bytes'); - header('Content-Length: '.$length); + header('Content-Length: '.filesize($nome)); header('Content-Type: image/png'); - print($img); - ob_end_flush(); + fpassthru(fopen($nome, 'rb')); exit; } - /* - if(file_exists($nome)) - { - if (!function_exists('imagepng')) - { - $s = PHP_SHLIB_SUFFIX; - @dl( 'php_gd.'.$s ); - if (!function_exists('imagepng')) - {@dl( 'php_gd2.'.$s );} - } - @$img = imagecreatefrompng($nome); - if(!$img) - { - $img = imagecreatetruecolor($w, $h); - imagealphablending($img, false); - imagesavealpha($img, true); - $bgc = imagecolorallocatealpha($img, 255, 255, 255,127); - $tc = imagecolorallocate($img, 255, 0, 0); - imagefilledrectangle($img, 0, 0, $w, $h, $bgc); - imagestring($img, 3, 5, 5, 'Erro ao ler ' . $nome, $tc); - } - else - { - imagealphablending($img, false); - imagesavealpha($img, true); - } - ob_clean(); - error_reporting(0); - echo header("Content-type: image/png \n\n"); - imagepng($img); - imagedestroy($img); - exit; - } - */ } function nomeRand($n=10) { diff --git a/classesphp/mapa_openlayers.php b/classesphp/mapa_openlayers.php index cc82c6f..bb1b44b 100644 --- a/classesphp/mapa_openlayers.php +++ b/classesphp/mapa_openlayers.php @@ -268,34 +268,10 @@ else{ $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; $img->saveImage($nomer); } - ob_start(); - // assuming you have image data in $imagedata - $img = file_get_contents($nomer); - $length = strlen($img); - $ft = filemtime($nomer); - if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { - // Client's cache IS current, so we just respond '304 Not Modified'. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); - } else { - // Image not cached or cache outdated, we respond '200 OK' and output the image. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); - } - header('Accept-Ranges: bytes'); - header('Content-Length: '.$length); + header('Content-Length: '.filesize($nomer)); header('Content-Type: image/png'); - print($img); - ob_end_flush(); + fpassthru(fopen($nomer, 'rb')); exit; -/* - ob_clean(); - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - imagedestroy($img); -*/ } function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ global $img,$map_size; @@ -309,10 +285,10 @@ function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ {$cachedir = dirname(dirname($map))."/cache/".$layer;} else {$cachedir = $cachedir."/".$layer;} - @mkdir($cachedir,0777); $nome = $cachedir."/".$w.$h.$bbox.".png"; if(!file_exists($nome)) { + @mkdir($cachedir,0777); $img->saveImage($nome); chmod($nome,0777); } @@ -330,61 +306,31 @@ function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ {$nome = $cachedir."/".$layer."/".$nome;} if(file_exists($nome)) { +/* + header('Accept-Ranges: bytes'); + header('Content-Length: '.filesize($nome)); + header('Content-Type: image/png'); + ob_start; + ob_flush(); + readfile($nome); + exit; + ob_start(); // assuming you have image data in $imagedata $img = file_get_contents($nome); $length = strlen($img); - $ft = filemtime($nome); - if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { - // Client's cache IS current, so we just respond '304 Not Modified'. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); - } else { - // Image not cached or cache outdated, we respond '200 OK' and output the image. - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); - } header('Accept-Ranges: bytes'); header('Content-Length: '.$length); header('Content-Type: image/png'); print($img); ob_end_flush(); exit; - } - /* - if (!function_exists('imagepng')) - { - $s = PHP_SHLIB_SUFFIX; - @dl( 'php_gd2.'.$s ); - if (!function_exists('imagepng')) - @dl( 'php_gd.'.$s ); - } - @$img = imagecreatefrompng($nome); - if(!$img) - { - // Create a blank image - $img = imagecreatetruecolor($w, $h); - imagealphablending($img, false); - imagesavealpha($img, true); - - $bgc = imagecolorallocatealpha($img, 255, 255, 255,127); - $tc = imagecolorallocate($img, 255, 0, 0); - - imagefilledrectangle($img, 0, 0, $w, $h, $bgc); - // Output an error message - imagestring($img, 3, 5, 5, 'Erro ao ler ' . $nome, $tc); - } - else - { - imagealphablending($img, false); - imagesavealpha($img, true); - } - ob_clean(); - error_reporting(0); - echo header("Content-type: image/png \n\n"); - imagepng($img); - imagedestroy($img); +*/ + header('Content-Length: '.filesize($nome)); + header('Content-Type: image/png'); + fpassthru(fopen($nome, 'rb')); exit; } - */ } function nomeRand($n=10) { -- libgit2 0.21.2