Ejemplo n.º 1
0
 /**
  * EXECUTE QUERY
  */
 function q_execMapQuery()
 {
     // use layers with complex queries that are too long to select results
     // cause maxscaledenom is not used...
     $oldDatas = array();
     for ($i = 0; $i < $this->map->numlayers; $i++) {
         $qLayer = $this->map->getLayer($i);
         if ($qLayer->getMetaData('PM_RESULT_DATASUBSTITION') != '') {
             $oldDatas[$i] = $qLayer->data;
             $qLayer->set('data', $qLayer->getMetaData('PM_RESULT_DATASUBSTITION'));
         }
     }
     // Patch from Alessandro Pasotti for fixing problems with result returned
     $this->map->setSize($this->mapwidth, $this->mapheight);
     // Set $this->map->extent to values of current map extent
     // otherwise values of TOLERANCE in map file are not interpreted correctly
     $this->map->setExtent($this->GEOEXT['minx'], $this->GEOEXT['miny'], $this->GEOEXT['maxx'], $this->GEOEXT['maxy']);
     $this->map->preparequery();
     // query by point
     if (count($this->imgxy_arr) == 2) {
         $this->pointQuery = 1;
         $this->x_pix = $this->imgxy_arr[0];
         $this->y_pix = $this->imgxy_arr[1];
         $x_geo = $this->minx_geo + $this->x_pix / $this->mapwidth * $this->xdelta_geo;
         $y_geo = $this->maxy_geo - $this->y_pix / $this->mapheight * $this->ydelta_geo;
         $XY_geo = ms_newPointObj();
         $XY_geo->setXY($x_geo, $y_geo);
         $searchArea = -1;
         // ===> USE TOLERANCE IN MAP FILE FOR EACH LAYER <===
         // Use '@' to avoid warning if query found nothing
         $qtype = $this->mode != "iquery" ? MS_MULTIPLE : MS_SINGLE;
         // MS_MULTIPLE for normal query, MS_SINGLE for iquery
         @$this->map->queryByPoint($XY_geo, $qtype, $searchArea);
         PMCommon::freeMsObj($XY_geo);
         // query by Rectangle
     } else {
         $this->pointQuery = 0;
         $minx_pix = $this->imgxy_arr[0];
         $miny_pix = $this->imgxy_arr[1];
         $maxx_pix = $this->imgxy_arr[2];
         $maxy_pix = $this->imgxy_arr[3];
         if ($minx_pix == $maxx_pix) {
             $maxx_pix = $maxx_pix + 2;
         }
         // increase max extent if min==max
         if ($miny_pix == $maxy_pix) {
             $maxy_pix = $maxy_pix - 2;
         }
         // -- " --
         $this->minx_sel_geo = $this->minx_geo + $minx_pix / $this->mapwidth * $this->xdelta_geo;
         $this->miny_sel_geo = $this->maxy_geo - $maxy_pix / $this->mapheight * $this->ydelta_geo;
         $this->maxx_sel_geo = $this->minx_geo + $maxx_pix / $this->mapwidth * $this->xdelta_geo;
         $this->maxy_sel_geo = $this->maxy_geo - $miny_pix / $this->mapheight * $this->ydelta_geo;
         $selrect = ms_newrectObj();
         $selrect->setExtent($this->minx_sel_geo, $this->miny_sel_geo, $this->maxx_sel_geo, $this->maxy_sel_geo);
         @$this->map->queryByRect($selrect);
         PMCommon::freeMsObj($selrect);
         //$queryFile = "d:/webdoc/tmp/qresults.txt";
         //$savedq = $this->map->savequery($queryFile);
         //printDebug($this->map->loadquery($queryFile));
         //error_log(
     }
     // use layers with complex queries that are too long to select results
     // cause maxscaledenom is not used...
     // reset data tag
     if (count($oldDatas)) {
         foreach ($oldDatas as $i => $v) {
             $qLayer = $this->map->getLayer($i);
             $qLayer->set('data', $v);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * EXECUTE QUERY
  */
 public function q_execMapQuery()
 {
     //--------------------------------
     // Initialize tolerance to 0
     //--------------------------------
     $msLayers = array();
     // query in specified groups only:
     if (isset($_REQUEST['groups']) && $_REQUEST['groups']) {
         $msLayers = getLayersByGroupOrLayerName($this->map, $_REQUEST['groups']);
         // all groups:
     } else {
         for ($i = 0; $i < $this->map->numlayers; $i++) {
             $msLayers[] = $this->map->getLayer($i);
         }
     }
     foreach ($msLayers as $msLayer) {
         // change tolerance only for buffer zone search.
         if ($this->queryType == 'object') {
             $msLayer->set('tolerance', 0);
         }
     }
     // Modified by Thomas RAFFIN (SIRAP)
     // to test (substitution)
     // query by point
     // Modified by Thomas RAFFIN (SIRAP)
     // use layers with complex queries that are too long to select results
     // cause maxscaledenom is not used...
     $oldDatas = array();
     for ($i = 0; $i < $this->map->numlayers; $i++) {
         $qLayer = $this->map->getLayer($i);
         $layerName = $qLayer->name;
         if ($qLayer->getMetaData('PM_RESULT_DATASUBSTITION') != '') {
             $oldDatas[$layerName] = $qLayer->data;
             $qLayer->set('data', $qLayer->getMetaData('PM_RESULT_DATASUBSTITION'));
         }
     }
     // few lines from incphp/query/query.php
     // Patch from Alessandro Pasotti for fixing problems with result returned
     $this->map->setSize($this->mapwidth, $this->mapheight);
     // Set $this->map->extent to values of current map extent
     // otherwise values of TOLERANCE in map file are not interpreted correctly
     $this->map->setExtent($this->GEOEXT['minx'], $this->GEOEXT['miny'], $this->GEOEXT['maxx'], $this->GEOEXT['maxy']);
     $this->map->preparequery();
     if ($this->queryType == 'object') {
         if (isset($_SESSION['pluginsConfig']['graphicalqueries']) && isset($_SESSION['pluginsConfig']['graphicalqueries']['bufferOnlyWithScale'])) {
             $bufferOnlyWithScale = $_SESSION['pluginsConfig']['graphicalqueries']['bufferOnlyWithScale'] == 1;
         } else {
             $bufferOnlyWithScale = true;
         }
         if (!$bufferOnlyWithScale) {
             //				PMCommon::setGroups($this->map, $this->querygroups, $this->scale, 0, 1);
             PMCommon::setGroups($this->map, $this->querygroups, 0, 0, 1);
         }
         // Search selected object
         $jsonPMResult = $_SESSION['JSON_Results'];
         // "[...]" ou "{...}"
         $PMResult = json_decode($jsonPMResult);
         // array ou class
         if ($PMResult) {
             $objUnion = false;
             // List layer of selected object
             $layersWithResult = $PMResult[0];
             // be carreful : 0.000000001 is too small !!
             $smallBuffer = 1.0E-8;
             $mapProjStr = $this->map->getProjection();
             if ($_SESSION['MS_VERSION'] < 6) {
                 $mapProjObj = ms_newprojectionobj($mapProjStr);
             } else {
                 $mapProjObj = new projectionObj($mapProjStr);
             }
             // Loop on layers
             $layerName = '';
             foreach ($layersWithResult as $layerWithResult) {
                 $objUnionLayer = false;
                 // init layer to close the last open one
                 $layer = false;
                 $layerProjObj = false;
                 // Loop on layer objects
                 foreach ($layerWithResult->values as $selectedObject) {
                     // layer name
                     $currentLayerName = $selectedObject[0]->shplink[0];
                     if ($currentLayerName != $layerName) {
                         if ($layer) {
                             $layer->close();
                         }
                         $layerName = $currentLayerName;
                         $layer = $this->map->getLayerByName($layerName);
                         $layerProjObj = false;
                         $layerProjStr = $layer->getProjection();
                         if ($mapProjStr && $layerProjStr && $mapProjStr != $layerProjStr) {
                             if ($_SESSION['MS_VERSION'] < 6) {
                                 $layerProjObj = ms_newprojectionobj($layerProjStr);
                             } else {
                                 $layerProjObj = new projectionObj($layerProjStr);
                             }
                         }
                         $layer->open();
                     }
                     $shpIndex = $selectedObject[0]->shplink[1];
                     // Retrieve shape by its index.
                     $objShape = PMCommon::resultGetShape($_SESSION['MS_VERSION'], $layer, null, $shpIndex, -1);
                     // changed for compatibility with PG layers and MS >= 5.6
                     // reproject
                     if ($layerProjObj) {
                         $objShape->project($layerProjObj, $mapProjObj);
                     }
                     // Union of the shapes
                     if ($objUnionLayer) {
                         $objUnionLayer = $objShape->union($objUnionLayer);
                     } else {
                         $objUnionLayer = $objShape;
                     }
                 }
                 // End foreach : Loop of the layer
                 // close layer if exists
                 if ($layer) {
                     $layer->close();
                 }
                 if ($objUnionLayer) {
                     // Line : Buffer to convert Line or Point to Polygon
                     if ($objUnionLayer->type == MS_SHAPE_LINE && isset($_REQUEST['select_buffer']) && $_REQUEST['select_buffer'] > 0 || $objUnionLayer->type == MS_SHAPE_POINT) {
                         $objUnionLayer = $objUnionLayer->buffer($smallBuffer);
                         // if polygon -> the outline is removed to not select contiguous objects
                     } else {
                         if ($objUnionLayer->type == MS_SHAPE_POLYGON && !isset($_REQUEST['select_buffer'])) {
                             $objBoundary = $objUnionLayer->boundary();
                             $objBoundary = $objBoundary->buffer($smallBuffer);
                             $objUnionLayer = $objUnionLayer->difference($objBoundary);
                         }
                     }
                 }
                 if ($objUnionLayer) {
                     if ($objUnion) {
                         $objUnion = $objUnion->union($objUnionLayer);
                     } else {
                         $objUnion = $objUnionLayer;
                     }
                 }
                 // End if($objUnionLayer)
             }
             // End foreach : loop of layers
             // Buffer -> Buffer zone
             if (isset($_REQUEST['select_buffer'])) {
                 if ($objUnion) {
                     $objUnion = $objUnion->buffer($_REQUEST['select_buffer']);
                     unset($_REQUEST['select_buffer']);
                 }
             }
             if ($objUnion) {
                 // Query
                 @$this->map->queryByShape($objUnion);
             }
         }
         // Query by point
     } else {
         if ($this->queryType == 'point') {
             $tmpPoint = ms_newPointObj();
             $tmpPoint->setXYZ($_REQUEST['select_pointX'], $_REQUEST['select_pointY'], 0);
             if (isset($_REQUEST['select_buffer'])) {
                 @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, $_REQUEST['select_buffer']);
             } else {
                 @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, -1);
             }
             PMCommon::freeMsObj($tmpPoint);
             // query by Shape
         } else {
             if ($this->queryType == 'polygon') {
                 //'shape')
                 $poly = $_REQUEST['select_poly'];
                 $tmpLine = ms_newLineObj();
                 $tmpPoly = explode(',', $poly);
                 foreach ($tmpPoly as $point) {
                     $tmpTab = explode(' ', $point);
                     $tmpLine->addXY($tmpTab[0], $tmpTab[1]);
                 }
                 $objPoly = ms_newShapeObj(MS_SHAPE_POLYGON);
                 $objPoly->add($tmpLine);
                 // Buffer -> Buffer zone
                 if (isset($_REQUEST['select_buffer'])) {
                     $objPoly = $objPoly->buffer($_REQUEST['select_buffer']);
                     unset($_REQUEST['select_buffer']);
                 }
                 @$this->map->queryByShape($objPoly);
                 PMCommon::freeMsObj($tmpLine);
                 PMCommon::freeMsObj($objPoly);
                 // query by PolyLine
             } else {
                 if ($this->queryType == 'line') {
                     $poly = $_REQUEST['select_line'];
                     $tmpLine = ms_newLineObj();
                     $tmpPoly = explode(',', $poly);
                     foreach ($tmpPoly as $point) {
                         $tmpTab = explode(' ', $point);
                         $tmpLine->addXY($tmpTab[0], $tmpTab[1]);
                     }
                     // Reduce the polygon to a polyline
                     for ($i = count($tmpPoly) - 1; $i >= 0; $i--) {
                         $tmpTab = explode(' ', $tmpPoly[$i]);
                         $tmpLine->addXY($tmpTab[0], $tmpTab[1]);
                     }
                     $objPoly = ms_newShapeObj(MS_SHAPE_POLYGON);
                     $objPoly->add($tmpLine);
                     // Buffer -> Buffer zone
                     if (isset($_REQUEST['select_buffer'])) {
                         $bufferLocal = $_REQUEST['select_buffer'];
                         if ($bufferLocal < 0) {
                             $bufferLocal = 0;
                         }
                         $objPoly = $objPoly->buffer($bufferLocal);
                         unset($_REQUEST['select_buffer']);
                     }
                     @$this->map->queryByShape($objPoly);
                     PMCommon::freeMsObj($tmpLine);
                     PMCommon::freeMsObj($objPoly);
                     // query by circle
                 } else {
                     if ($this->queryType == 'circle') {
                         $point = $_REQUEST['select_point'];
                         $radius = $_REQUEST['select_radius'];
                         $tmpPoint = ms_newPointObj();
                         $tmpTab = explode(' ', $point);
                         $tmpPoint->setXYZ($tmpTab[0], $tmpTab[1], 0);
                         if (isset($_REQUEST['select_buffer'])) {
                             @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, $radius + $_REQUEST['select_buffer']);
                         } else {
                             @$this->map->queryByPoint($tmpPoint, MS_MULTIPLE, $radius);
                         }
                         PMCommon::freeMsObj($tmpPoint);
                     }
                 }
             }
         }
     }
     // Modified by Thomas RAFFIN (SIRAP)
     // use layers with complex queries that are too long to select results
     // cause maxscaledenom is not used...
     // reset data tag
     foreach ($oldDatas as $qLayer => $oldData) {
         $qLayer = $this->map->getLayerByName($qLayer);
         $qLayer->set('data', $oldData);
     }
 }
Ejemplo n.º 3
0
function reprojectPoint(&$nX, &$nY, $szFrom, $szTo)
{
    //echo "reproject $nX,$nY from $szFrom to $szTo\n";
    //check to see if reprojection is necessary
    if ($szFrom == '' || $szTo == '') {
        return;
    }
    if (stristr($szFrom, "epsg") !== false && stristr($szFrom, "init=") == false) {
        $szFrom = "init=" . strtolower($szFrom);
    }
    if (stristr($szTo, "epsg") !== false && stristr($szTo, "init=") == false) {
        $szTo = "init=" . strtolower($szTo);
    }
    if ($szFrom == $szTo) {
        return;
    }
    $oPoint = ms_newPointObj();
    $oPoint->setXY($nX, $nY);
    $oPoint->project(ms_newProjectionObj($szFrom), ms_newProjectionObj($szTo));
    $nX = $oPoint->x;
    $nY = $oPoint->y;
    //echo " :".$nX." ,".$nY."<br>";
}
Ejemplo n.º 4
0
function xy2imagem($map_file, $xy, $map = "")
{
    if (!is_array($xy)) {
        $xy = explode(" ", $xy);
    }
    $pt = ms_newPointObj();
    include dirname(__FILE__) . "/../ms_configura.php";
    if ($map == "") {
        $map = ms_newMapObj($map_file);
        substituiConObj($map, $postgis_mapa);
        $map = desligatemas($map);
        $map = desligamargem($map);
        $imgo = $map->draw();
    }
    $e = $map->extent;
    $vx = $e->minx * -1 - $xy[0] * -1;
    $vy = $xy[1] * -1 + $e->maxy * 1;
    $c = $map->cellsize;
    $x = $vx / $c;
    $y = $vy / $c;
    $pt->setXY($x, $y);
    return $pt;
}
Ejemplo n.º 5
0
 function identificaQBP3($tema = "", $x = 0, $y = 0, $map_file = "", $resolucao = 0, $item = "", $tiporetorno = "", $etip = false, $ext = "", $wkt = "nao")
 {
     if ($map_file == "") {
         $mapa = $this->mapa;
         $map_file = $this->arquivo;
     } else {
         $mapa = ms_newMapObj($map_file);
     }
     if ($ext != "") {
         $extmapa = $mapa->extent;
         $e = explode(" ", $ext);
         $extmapa->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
         //$mapa->save($this->arquivo);
     }
     if ($tema == "") {
         $layer = $this->layer;
     } else {
         $layer = $mapa->getLayerByName($tema);
     }
     $layer->set("status", MS_DEFAULT);
     $layer->set("template", "none.htm");
     $pt = ms_newPointObj();
     $pt->setXY($x, $y);
     if (strtoupper($layer->getmetadata("convcaracter")) == "NAO") {
         $convC = false;
     } else {
         $convC = true;
     }
     //
     //opera&ccedil;&atilde;o especial para o caso de wms
     //
     if ($layer->connectiontype == MS_WMS) {
         $wkt = "nao";
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $mapa = desligatemas($mapa);
         $mapa = desligamargem($mapa);
         $imgo = $mapa->draw();
         $ptimg = xy2imagem($map_file, array($x, $y), $mapa);
         //$formatoinfo = "MIME";
         $formatosinfo = $layer->getmetadata("formatosinfo");
         if ($formatosinfo != "") {
             $formatosinfo = explode(",", $formatosinfo);
             if ($formatosinfo[0] != "") {
                 $formatoinfo = $formatosinfo[0];
             }
             foreach ($formatosinfo as $f) {
                 if (strtoupper($f) == "TEXT/PLAIN") {
                     $formatoinfo = "text/plain";
                 }
             }
         } else {
             $formatoinfo = $layer->getmetadata("wms_feature_info_type");
             if ($formatoinfo == "") {
                 $formatoinfo = $layer->getmetadata("wms_feature_info_mime_type");
             }
             if ($formatoinfo == "") {
                 $formatoinfo = "text/plain";
             }
         }
         $res = $layer->getWMSFeatureInfoURL($ptimg->x, $ptimg->y, 1, $formatoinfo);
         $res = str_replace("INFOFORMAT", "INFO_FORMAT", $res);
         $res2 = $layer->getWMSFeatureInfoURL($ptimg->x, $ptimg->y, 1, "MIME");
         $res2 = str_replace("INFOFORMAT", "INFO_FORMAT", $res2);
         //echo $res." ".$res2;exit;
         $resposta = file($res);
         //var_dump($resposta);exit;
         $n = array();
         if (strtoupper($formatoinfo) != "TEXT/HTML" && strtoupper($formatoinfo) != "MIME") {
             foreach ($resposta as $r) {
                 $t = explode("=", $r);
                 if (count($t) > 1) {
                     $v = str_replace("\\n", "", $t[1]);
                     $v = str_replace("\\r", "", $v);
                     if (trim($v) != "") {
                         $va = trim($v);
                         if ($convC == true) {
                             $va = $this->converte($va);
                         }
                         $n[] = array("alias" => trim($t[0]), "valor" => $va, "link" => "", "img" => "");
                     }
                 }
             }
             //caso esri
             if (count($n) > 0 && $n[0] == "") {
                 //error_reporting(0);
                 $resposta = file($res);
                 $cabecalho = str_replace('"   "', '"|"', $resposta[0]);
                 $cabecalho = explode("|", $cabecalho);
                 $linha = str_replace('"  "', '"|"', $resposta[1]);
                 $linha = explode("|", $linha);
                 for ($i = 0; $i < count($cabecalho); ++$i) {
                     if ($convC == true) {
                         $va = $this->converte($linha[$i]);
                     } else {
                         $va = $linha[$i];
                     }
                     $n[] = array("alias" => $cabecalho[$i], "valor" => $va, "link" => "", "img" => "");
                 }
             }
         }
         //var_dump($n);exit;
         $id = nomeRandomico();
         if (count($n) == 0 && strtoupper($formatoinfo) != "TEXT/HTML") {
             $formatoinfo = "MIME";
         }
         if (strtoupper($formatoinfo) == "TEXT/HTML" && $res != "") {
             $n[] = array("alias" => "", "valor" => "<iframe width=250px id='" . $id . "' name='" . $id . "' src='" . $res . "'></iframe>", "link" => "", "img" => "");
         }
         if (strtoupper($formatoinfo) == "MIME" && $res2 != "") {
             $n[] = array("alias" => "", "valor" => "<iframe width=250px id='" . $id . "' name='" . $id . "' src='" . $res2 . "'></iframe>", "link" => "", "img" => "");
         }
         if ($res != "") {
             $n[] = array("alias" => "Link WMS", "valor" => "getfeatureinfo " . $formatoinfo, "link" => $res, "img" => "", "idIframe" => $id);
         }
         if ($res2 != "") {
             $n[] = array("alias" => "Link WMS", "valor" => "getfeatureinfo padr&atilde;o do servi&ccedil;o", "link" => $res2, "img" => "", "idIframe" => $id);
         }
         if ($res == "" && $res2 == "") {
             $n[] = array("alias" => "Ocorreu um erro", "valor" => "", "link" => "", "img" => "");
         }
         return array($n);
     }
     //se o usuario estiver logado e o tema for editavel, a lista de itens
     //nao usa os alias para permitir a edicao dos dados
     if (!empty($_COOKIE["i3geocodigologin"]) && $layer->getmetadata("EDITAVEL") == "SIM") {
         $itens = "";
         $itensdesc = "";
         $lks = "";
         $itemimg = "";
         $locimg = "";
     } else {
         $itens = $layer->getmetadata("ITENS");
         // itens
         $itensdesc = $layer->getmetadata("ITENSDESC");
         // descri&ccedil;&atilde;o dos itens
         $lks = $layer->getmetadata("ITENSLINK");
         // link dos itens
         $itemimg = $layer->getmetadata("ITEMIMG");
         //indica um item que ser&aacute; utilizado para colocar um &iacute;cone
         $locimg = $layer->getmetadata("IMGLOC");
         //indica o local onde est&atilde;o os &iacute;cones
     }
     $tips = $layer->getmetadata("TIP");
     $itensLayer = pegaItens($layer, $mapa);
     $nitens = count($itensLayer);
     if ($itens == "") {
         $itens = $itensLayer;
     } else {
         $itens = explode(",", $itens);
     }
     if ($itensdesc == "") {
         $itensdesc = $itensLayer;
     } else {
         $itensdesc = explode(",", $itensdesc);
     }
     if ($lks == "") {
         $lks = array_fill(0, $nitens - 1, '');
     } else {
         $lks = explode(",", $lks);
     }
     if ($itemimg == "") {
         $itemimg = array_fill(0, $nitens - 1, '');
     } else {
         $itemimg = explode(",", $itemimg);
     }
     if ($locimg == "") {
         $locimg = array_fill(0, $nitens - 1, '');
     } else {
         $locimg = explode(",", $locimg);
     }
     $tips = str_replace(" ", ",", $tips);
     $tips = explode(",", $tips);
     //o retorno deve ser do tipo TIP
     if ($etip == true) {
         $temp = array_combine($itens, $itensdesc);
         $templ = array_combine($itens, $lks);
         $tempimg = array_combine($itens, $itemimg);
         $temploc = array_combine($itens, $locimg);
         $itensdesc = array();
         $itens = array();
         $lks = array();
         $itemimg = array();
         $locimg = array();
         //foreach($tips as $t){
         foreach ($itensLayer as $t) {
             $itens[] = $t;
             if ($temp[$t] != "") {
                 $itensdesc[] = $temp[$t];
             } else {
                 $itensdesc[] = $t;
             }
             if ($templ[$t] != "") {
                 $lks[] = $templ[$t];
             } else {
                 $lks[] = "";
             }
             if ($tempimg[$t] != "") {
                 $itemimg[] = $tempimg[$t];
             } else {
                 $itemimg[] = "";
             }
             if ($temploc[$t] != "") {
                 $locimg[] = $temploc[$t];
             } else {
                 $locimg[] = "";
             }
         }
     }
     if ($layer->connectiontype != MS_WMS && $layer->type == MS_LAYER_RASTER) {
         $wkt = "nao";
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $ident = @$layer->queryByPoint($pt, 0, 0);
         //0.01);
     }
     if ($layer->type == MS_LAYER_POINT || $layer->type == MS_LAYER_LINE || $layer->type == MS_LAYER_CHART) {
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $ident = @$layer->queryByPoint($pt, 1, -1);
         //0.01);
     }
     if ($layer->type == MS_LAYER_POLYGON) {
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $ident = @$layer->queryByPoint($pt, 1, -1);
     }
     if ($ident == MS_SUCCESS) {
         //$ident = @$layer->queryByPoint($pt, 1, -1);
         //verifica se o layer e editavel no sistema METAESTAT
         $editavel = "nao";
         //
         $sopen = $layer->open();
         $res_count = $layer->getNumresults();
         if (strtoupper($layer->getmetadata("convcaracter")) == "NAO") {
             $convC = false;
         } else {
             $convC = true;
         }
         if ($sopen == MS_FAILURE) {
             return "erro";
         }
         for ($i = 0; $i < $res_count; ++$i) {
             $valori = array();
             if ($this->v >= 6) {
                 $shape = $layer->getShape($layer->getResult($i));
             } else {
                 $result = $layer->getResult($i);
                 $shp_index = $result->shapeindex;
                 $shape = $layer->getfeature($shp_index, -1);
             }
             $conta = 0;
             //var_dump($itens);exit;
             if ($tiporetorno == "shape" || $tiporetorno == "googlerelevo") {
                 if ($tiporetorno == "shape") {
                     $resultado[] = $shape;
                 }
                 if ($tiporetorno == "googlerelevo") {
                     $lin = $shape->line(0);
                     $p = $lin->point(0);
                     $resultado = array("elevation" => $shape->values[$item], "location" => array("lat" => $p->x, "lng" => $p->y));
                 }
             } else {
                 if ($etip == false && $item != "") {
                     $resultado[] = $shape->values[$item];
                 } else {
                     //var_dump($itens);exit;
                     foreach ($itens as $it) {
                         $val = $shape->values[$it];
                         if ($convC == true) {
                             $val = $this->converte($val);
                         }
                         $link = $lks[$conta];
                         foreach ($itens as $t) {
                             $valtemp = $shape->values[$t];
                             $busca = '[' . $t . ']';
                             $link = str_replace($busca, $valtemp, $link);
                         }
                         $img = "";
                         if ($locimg[$conta] != "" && $itemimg[$conta] != "") {
                             $img = "<img src='" . $locimg[$conta] . "//" . $shape->values[$itemimg[$conta]] . "' //>";
                         } else {
                             if ($itemimg[$conta] != "") {
                                 $img = "<img src='" . $shape->values[$itemimg[$conta]] . "' //>";
                             }
                         }
                         //indica se o item &eacute; tbm uma etiqueta
                         $etiqueta = "nao";
                         if (in_array($it, $tips)) {
                             $etiqueta = "sim";
                         }
                         $arraytemp = array("item" => $it, "alias" => $this->converte($itensdesc[$conta]), "valor" => $val, "link" => $link, "img" => $img, "tip" => $etiqueta);
                         if ($etip == false) {
                             $valori[] = $arraytemp;
                         } else {
                             $valori[$it] = $arraytemp;
                         }
                         $conta = $conta + 1;
                     }
                     if ($wkt == "sim") {
                         $arraytemp = array("alias" => "wkt", "valor" => $shape->towkt(), "link" => "", "img" => "", "tip" => "");
                         $valori[] = $arraytemp;
                     }
                     $resultado[] = $valori;
                 }
             }
         }
         $layer->close();
     } else {
         $resultado[] = " ";
     }
     if ($etip == true) {
         return array("resultado" => $resultado, "itensLayer" => $itensLayer);
     } else {
         return $resultado;
     }
 }
Ejemplo n.º 6
0
 function selecaoPT($xy, $tipo, $tolerancia)
 {
     if ($tipo == "novo") {
         $this->selecaoLimpa();
         $tipo = "adiciona";
     }
     if ($tipo == "limpa") {
         return $this->selecaoLimpa();
     }
     if ($tipo == "inverte") {
         return $this->selecaoInverte();
     }
     if (!$this->layer) {
         return "erro";
     }
     $shp_atual = array();
     if ($this->qyfileTema != "" && file_exists($this->qyfileTema)) {
         $shp_atual = $this->unserializeQ($this->qyfileTema);
     }
     $shpi = array();
     $c = explode(" ", $xy);
     $pt = ms_newPointObj();
     $pt->setXY($c[0], $c[1]);
     if ($tolerancia == 0) {
         $this->layer->set("tolerance", 0);
         $this->layer->set("toleranceunits", 6);
         if ($this->layer->type == MS_LAYER_POINT || $this->layer->type == MS_LAYER_LINE) {
             $this->layer->set("tolerance", 5);
             $ident = @$this->layer->queryByPoint($pt, 1, 0);
         } else {
             $ident = @$this->layer->queryByPoint($pt, 1, 0);
         }
     } else {
         error_reporting(0);
         $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs");
         $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=0,lon_0=" . $pt->x . ",x_0=5000000,y_0=10000000");
         $poPoint = ms_newpointobj();
         $poPoint->setXY($pt->x, $pt->y);
         //$dd1 = ms_newpointobj();
         //$dd1->setXY($rect->minx, $rect->miny);
         $poPoint->project($projInObj, $projOutObj);
         $dd2 = ms_newpointobj();
         $dd2->setXY($poPoint->x + $tolerancia, $poPoint->y);
         $dd2->project($projOutObj, $projInObj);
         $d = $pt->distanceToPoint($dd2);
         if ($d < 0) {
             $d = $d * -1;
         }
         //calcula a distancia 29100
         //gera o buffer
         $s = ms_newShapeObj(MS_SHAPE_POINT);
         $linha = ms_newLineObj();
         $linha->add($pt);
         $s->add($linha);
         $buffer = $s->buffer($d);
         $ident = @$this->layer->queryByShape($buffer);
     }
     if ($ident != 1) {
         $res_count = $this->layer->getNumresults();
         $shpi = array();
         for ($i = 0; $i < $res_count; ++$i) {
             $result = $this->layer->getResult($i);
             $shpi[] = $result->shapeindex;
         }
     }
     if ($tipo == "adiciona") {
         return $this->selecaoAdiciona($shpi, $shp_atual);
     }
     if ($tipo == "retira") {
         return $this->selecaoRetira($shpi, $shp_atual);
     }
 }
Ejemplo n.º 7
0
function ProcesaROI(&$aROI)
{
    // debug
    //renderText(count($_SESSION['ROIRENDERER']));
    $aPoints = array();
    if ($aROI['type'] == 'rectangle') {
        //for rectangles, we assume that there are two coordinates, top left and bottom right.
        array_push($aPoints, $aROI['aGeoCoords'][0]);
        array_push($aPoints, $aROI['aGeoCoords'][1]);
        array_push($aPoints, $aROI['aGeoCoords'][2]);
        array_push($aPoints, $aROI['aGeoCoords'][1]);
        array_push($aPoints, $aROI['aGeoCoords'][2]);
        array_push($aPoints, $aROI['aGeoCoords'][3]);
        array_push($aPoints, $aROI['aGeoCoords'][0]);
        array_push($aPoints, $aROI['aGeoCoords'][3]);
        array_push($aPoints, $aROI['aGeoCoords'][0]);
        array_push($aPoints, $aROI['aGeoCoords'][1]);
        $nPoints = 5;
        // flag for poly
        $bPoly = true;
    } elseif ($aROI['type'] == 'circle') {
        // convert center and radius to pixel
        $dCenterX = $aROI['aGeoCoords'][0];
        $dCenterY = $aROI['aGeoCoords'][1];
        $dRadiusX = $aROI['aGeoCoords'][2];
        $dRadius = abs($dRadiusX - $dCenterX);
        // flag for non-poly
        $bPoly = false;
    } elseif ($aROI['type'] == 'polygon') {
        // loop and set coordinates
        $nCount = count($aROI['aGeoCoords']);
        for ($i = 0; $i < $nCount; $i++) {
            array_push($aPoints, $aROI['aGeoCoords'][$i]);
        }
        array_push($aPoints, $aROI['aGeoCoords'][0]);
        array_push($aPoints, $aROI['aGeoCoords'][1]);
        $nPoints = round($nCount / 2);
        // flag for poly
        $bPoly = true;
    } elseif ($aROI['type'] == 'line') {
        // Only mode 1 and 2 (add) is supported for now.
        if ($aROI['mode'] != 1 and $aROI['mode'] != 2) {
            $this->maszErrorMsg[] = "Tipo de Elemento inválido. " . "Sólo agregar elementos está habilitado";
        }
        // For a line, we have a pair of value for each vertex.
        $nVertex = count($aROI['aGeoCoords']);
        for ($i = 0; $i < $nVertex; $i++) {
            array_push($aPoints, $aROI['aGeoCoords'][$i]);
        }
    } elseif ($aROI['type'] == 'point') {
        // Only mode 1 and 2 (add) is supported for now.
        if ($aROI['mode'] != 1 and $aROI['mode'] != 2) {
            $this->maszErrorMsg[] = "Tipo de Elemento inválido. " . "Sólo agregar elementos está habilitado";
        }
        array_push($aPoints, $aROI['aGeoCoords'][0]);
        array_push($aPoints, $aROI['aGeoCoords'][1]);
    } elseif ($aROI['type'] == 'feature') {
        $nPoints = 0;
        $nLayers = $GLOBALS['oMapSession']->oMap->numlayers;
        for ($i = 0; $i < $nLayers; $i++) {
            $oLayer = $GLOBALS['oMapSession']->oMap->getLayer($i);
            $oLayer->set('status', MS_OFF);
        }
        $oLayer = @$GLOBALS['oMapSession']->oMap->getLayerByName($aROI['selectedLayer']);
        if ($oLayer && $oLayer->type == MS_LAYER_POLYGON) {
            $nResults = 0;
            //create the query template that turns polygons into something useful.
            $szTemplatePath = getSessionSavePath() . "roirenderer_template.html";
            if (!file_exists($szTemplatePath)) {
                $szTemplate = '[shpxy xf="," yf="," sf="|" proj="image"]';
                $hTemplate = fopen($szTemplatePath, "w+");
                fwrite($hTemplate, $szTemplate);
                fclose($hTemplate);
            }
            //put the template on each class ... is this necessary?
            for ($i = 0; $i < $oLayer->numclasses; $i++) {
                $oClass = $oLayer->getClass($i);
                $oClass->set("template", $szTemplatePath);
            }
            //make sure the layer is on (doh)
            $oLayer->set("status", MS_ON);
            $oLayer->set('tolerance', 0);
            $oLayer->set('toleranceunits', MS_PIXELS);
            //its a new query ...
            if (count($aROI['aGeoCoords']) == 2) {
                $aROI['aOrigCoords'] = $aROI['aGeoCoords'];
                $oPoint = ms_newPointObj();
                $oPoint->setXY($aROI['aGeoCoords'][0], $aROI['aGeoCoords'][1]);
                @$oLayer->queryByPoint($oPoint, MS_SINGLE, 0);
                $nResults = $oLayer->getNumResults();
                unset($aROI['aGeoCoords']);
                if ($nResults > 0) {
                    //save the query results for future passes ...
                    $aROI['query_file'] = getSessionSavePath() . "/" . uniqid("") . ".qry";
                    $GLOBALS['oMapSession']->oMap->saveQuery($aROI['query_file']);
                }
            } else {
                if (isset($aROI['query_file']) && file_exists($aROI['query_file'])) {
                    //load the query and find a layer with query results ...
                    $GLOBALS['oMapSession']->oMap->loadQuery($aROI['query_file']);
                    $nResults = $oLayer->getNumResults();
                }
            }
            if ($nResults > 0) {
                $szCode = $GLOBALS['oMapSession']->oMap->processQueryTemplate(array(), false);
                //there seems to be a bug ... query results are not getting reset ... so we
                //introduce a | after each shape and then only take the first shape ...
                $aszCode = explode("|", $szCode);
                $szCode = substr($aszCode[0], 0, -1);
                $szCode = '$' . 'aPoints = array(' . $szCode . ');';
                //?? aqui se debería procesar los puntos de coord mapa a Pix
                eval($szCode);
                $nPoints = count($aPoints) / 2;
                $bPoly = true;
            }
        }
    }
    return $aPoints;
}
Ejemplo n.º 8
0
    $pt->setXY($ISUAGcities[$key]['lon'], $ISUAGcities[$key]['lat'], 0);
    $pt->draw($map, $snet, $img, 1, round($value, $rnd[$var]));
    // Climate
    if ($var == "gdd32" || $var == "gdd50" || $var == "prec") {
        $pt = ms_newPointObj();
        $pt->setXY($ISUAGcities[$key]['lon'], $ISUAGcities[$key]['lat'], 0);
        $pt->draw($map, $snet, $img, 2, "(" . round($value - $climate[$key][$var], $rnd[$var]) . ")");
    }
    if (isset($_GET["var2"])) {
        // Value LL
        $pt = ms_newPointObj();
        $pt->setXY($ISUAGcities[$key]['lon'], $ISUAGcities[$key]['lat'], 0);
        if ($var2 == 'c530') {
            $pt->draw($map, $snet, $img, 2, $row[$var2] . " " . $row[$var2 . '_f']);
        } else {
            $pt->draw($map, $snet, $img, 2, round($row[$var2], $rnd[$var2]) . " " . $row[$var2 . '_f']);
        }
    }
    // City Name
    $pt = ms_newPointObj();
    $pt->setXY($ISUAGcities[$key]['lon'], $ISUAGcities[$key]['lat'], 0);
    if ($key == "A131909" || $key == "A130209") {
        $pt->draw($map, $snet, $img, 0, $ISUAGcities[$key]['name']);
    } else {
        $pt->draw($map, $snet, $img, 0, $ISUAGcities[$key]['name']);
    }
}
iemmap_title($map, $img, $year . " " . $varDef[$var], "(" . $sstr_txt . " - " . $estr_txt . ")");
$map->drawLabelCache($img);
header("Content-type: image/png");
$img->saveImage('');
Ejemplo n.º 9
0
function getMercatorExtent($x, $y, $z)
{
    $grid_count = pow(2, $z);
    $block_size = 360.0 / $grid_count;
    $temp_x = -180.0 + $block_size * $x;
    $temp_y = 180.0 - $block_size * $y;
    $temp_x2 = $temp_x + $block_size;
    $temp_y2 = $temp_y - $block_size;
    $lon = $temp_x;
    $lat = (2.0 * atan(exp($temp_y / 180.0 * pi())) - pi() / 2.0) * 180.0 / pi();
    $lon2 = $temp_x2;
    $lat2 = (2.0 * atan(exp($temp_y2 / 180.0 * pi())) - pi() / 2.0) * 180.0 / pi();
    $projIn = ms_newProjectionObj("proj=latlong");
    $projOut = ms_newProjectionObj("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +units=m +k=1.0 +nadgrids=@null");
    $sw = ms_newPointObj();
    $ne = ms_newPointObj();
    $sw->setXY($lon, $lat2);
    $ne->setXY($lon2, $lat);
    $sw->project($projIn, $projOut);
    $ne->project($projIn, $projOut);
    $array = array();
    $array[0] = $sw->x;
    $array[1] = $sw->y;
    $array[2] = $ne->x;
    $array[3] = $ne->y;
    return $array;
}
Ejemplo n.º 10
0
Archivo: map.php Proyecto: sukma279/GIS
 /**
  * DRAW XY LAYER: ADD POINTS FROM DB TO MAP IMAGE
  */
 protected function pmap_drawXYLayer($img)
 {
     $grouplist = $_SESSION["grouplist"];
     // Loop through groups and layers to find XYLayers
     foreach ($grouplist as $grp) {
         $glayerList = $grp->getLayers();
         foreach ($glayerList as $glayer) {
             $XYLayerProperties = $glayer->getXYLayerProperties();
             if ($XYLayerProperties) {
                 // XYLayer found, now process
                 $mLayer = $this->map->getLayer($glayer->getLayerIdx());
                 $mLayerStatus = $mLayer->status;
                 if ($mLayerStatus == MS_ON) {
                     // Check if XYLayer is switched ON
                     $pearDbClass = $_SESSION['pearDbClass'];
                     require_once "{$pearDbClass}.php";
                     require_once "../query/query.php";
                     // Check if Layer projection differs from Map projection
                     $changeLayProj = PMCommon::checkProjection($this->map, $mLayer);
                     // Map extent for limiting query
                     if ($changeLayProj) {
                         $me = $this->map->extent;
                         $mapExt = ms_newRectObj();
                         $mapExt->setExtent($me->minx, $me->miny, $me->maxx, $me->maxy);
                         $mapExt->project($changeLayProj['mapProj'], $changeLayProj['layProj']);
                     } else {
                         $mapExt = $this->map->extent;
                     }
                     $map_xmin = $mapExt->minx;
                     $map_ymin = $mapExt->miny;
                     $map_xmax = $mapExt->maxx;
                     $map_ymax = $mapExt->maxy;
                     if ($changeLayProj) {
                         PMCommon::freeMsObj($mapExt);
                     }
                     // XY Layer Properties
                     $dsn = $XYLayerProperties["dsn"];
                     $xyTable = $XYLayerProperties["xyTable"];
                     $x_fld = $XYLayerProperties["x_fld"];
                     $y_fld = $XYLayerProperties["y_fld"];
                     $classidx_fld = $XYLayerProperties["classidx_fld"];
                     $resFldStr = $mLayer->getMetaData("RESULT_FIELDS");
                     $resFieldList = preg_split('/[\\s,]+/', $resFldStr);
                     // Prepare query
                     if (preg_match("/@/", $xyTable)) {
                         // Check for WHERE filter in table definition
                         $xyList = preg_split('/@/', $xyTable);
                         $whereFilter = $xyList[1];
                         $xyTable = $xyList[0];
                     }
                     $sql_SELECT = "SELECT {$x_fld}, {$y_fld}, {$classidx_fld} FROM {$xyTable} ";
                     $sql_WHERE = "WHERE " . ($whereFilter ? $whereFilter . " AND " : "") . " {$x_fld} >= {$map_xmin}  AND {$x_fld} <= {$map_xmax} AND {$y_fld} >= {$map_ymin} AND {$y_fld} <= {$map_ymax}";
                     $sql = "{$sql_SELECT}  {$sql_WHERE}";
                     pm_logDebug(3, $sql, "P.MAPPER-DEBUG: map.php/pmap_drawXYLayer() - SQL Cmd:");
                     // init DB class
                     $db = new $pearDbClass();
                     // Connect to DB
                     $dbh = $db->connect($dsn);
                     if ($db->isError($dbh)) {
                         PMCommon::db_logErrors($dbh);
                         die;
                     }
                     // Execute query
                     $res = $dbh->query($sql);
                     if ($db->isError($res)) {
                         PMCommon::db_logErrors($res);
                         die;
                     }
                     // Draw points on map image
                     while ($xyRow = $res->fetchRow()) {
                         $ptX = $xyRow[0];
                         $ptY = $xyRow[1];
                         $clIdx = $xyRow[2];
                         $xyPoint = ms_newPointObj();
                         $xyPoint->setXY($ptX, $ptY);
                         $xyPoint->draw($this->map, $mLayer, $img, $clIdx, "");
                         PMCommon::freeMsObj($xyPoint);
                     }
                     //$res->free();
                     $dbh->disconnect();
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Process request
  */
 function process_request()
 {
     $layer = @$this->map_object->getLayerByName($this->typename);
     if (!$layer) {
         $this->set_error('Layer not found ' . $layer_name, $layer_name);
         return false;
     }
     // Get class
     $class = null;
     for ($i = 0; $i < $layer->numclasses; $i++) {
         $_class = @$layer->getClass($i);
         if ($this->classname == $_class->name) {
             $class =& $_class;
             $this->classindex = $i;
             break;
         }
     }
     if (!$class) {
         $this->set_error('Class name not found ' . $layer_name, $this->classname);
         return false;
     }
     // Get symbol size
     for ($i = 0; $i < $class->numstyles; $i++) {
         $_style = @$class->getStyle($i);
         if ($_style->symbolname) {
             // 64 pixel is standard Google Earth pushpin
             //$_style->set('size', 64);
             $symbolsize = $_style->size;
             break;
         }
     }
     // Provide a default here
     if (!$symbolsize) {
         $symbolsize = 10;
     }
     $ext = $this->map_object->extent;
     $centerx = ($ext->maxx - $ext->minx) / 2;
     $centery = ($ext->maxy - $ext->miny) / 2;
     // Create a new layer
     $this->icon_layer = ms_newLayerObj($this->map_object, $layer);
     $this->map_object->setSize($symbolsize, $symbolsize);
     $this->map_object->setExtent($centerx - $symbolsize, $centery - $symbolsize, $centerx + $symbolsize, $centery + $symbolsize);
     $this->icon_layer->set('status', MS_ON);
     $this->iconpoint = ms_newPointObj();
     $this->iconpoint->setXY($centerx, $centery);
 }
Ejemplo n.º 12
0
 function zoomPonto($xy)
 {
     $apt = explode(" ", $xy);
     $pt = ms_newPointObj();
     $e = $this->mapa->extent;
     $pt = xy2imagem($this->arquivo, $xy);
     $this->mapa->zoompoint(1, $pt, $this->mapa->width, $this->mapa->height, $e);
 }
Ejemplo n.º 13
0
    $sizey = $zSizey;
} else {
    $zSizex = $sizex;
    $zSizey = $sizey;
}
if (!is_array($ext)) {
    $zExtent = $zMap->extent;
} elseif (!empty($fsens)) {
    $fext = move_map($ext, $fsens);
    $zExtent = ms_newRectObj();
    $zExtent->setextent($fext[0], $fext[1], $fext[2], $fext[3]);
} else {
    $zExtent = ms_newRectObj();
    $zExtent->setextent($ext[0], $ext[1], $ext[2], $ext[3]);
}
$zClick = ms_newPointObj();
if ($act and ($refx and $refy) and sizeof($ext) > 3) {
    $refx = floor($refx * ($sizex / $conf[globals][minimapx]));
    $refy = floor($refy * ($sizey / $conf[globals][minimapy]));
    $zClick->setXY($refx, $refy, 0);
    $zMap->zoomscale($scl * 1000, $zClick, $sizex, $sizey, $zLimit, $zLimit);
} else {
    if ($act != "edition" and $click_x and $click_y) {
        $zClick->setXY($click_x, $click_y, 0);
        $clicked = TRUE;
    } else {
        $zClick->setXY(floor($sizex / 2), floor($sizey / 2), 0);
        $clicked = FALSE;
    }
    if ($clicked and ($act == "zoomin" or !empty($fzoom))) {
        $zMap->zoompoint(2, $zClick, $sizex, $sizey, $zExtent, $zLimit);
Ejemplo n.º 14
0
function ProcessURLArray($aVars)
{
    //simpan tool navigasi yang sedang aktif
    $GLOBALS["gszCurrentTool"] = isset($aVars["CMD"]) ? $aVars["CMD"] : "ZOOM_IN";
    //set batas koordinat peta
    $oExt = $GLOBALS["goMap"];
    $fMinX = isset($aVars["MINX"]) ? $aVars["MINX"] : $oExt->extent->minx;
    $fMinY = isset($aVars["MINY"]) ? $aVars["MINY"] : $oExt->extent->miny;
    $fMaxX = isset($aVars["MAXX"]) ? $aVars["MAXX"] : $oExt->extent->maxx;
    $fMaxY = isset($aVars["MAXY"]) ? $aVars["MAXY"] : $oExt->extent->maxy;
    $GLOBALS["goMap"]->setextent($fMinX, $fMinY, $fMaxX, $fMaxY);
    //lebar dan tinggi gambar peta
    $fW = $GLOBALS["goMap"]->width;
    $fH = $GLOBALS["goMap"]->height;
    if (isset($_GET["legendlayername"])) {
        for ($i = 0; $i < $GLOBALS["goMap"]->numlayers; $i++) {
            $oLayer = $GLOBALS["goMap"]->getLayer($i);
            if (in_array($oLayer->name, $_GET["legendlayername"])) {
                $oLayer->set("status", MS_ON);
            } else {
                $oLayer->set("status", MS_OFF);
            }
        }
    }
    //lakukan perubahan skala, sesuai tool navigasi terpilih
    if (isset($aVars["CMD"]) && isset($aVars["MAINMAP_x"])) {
        //titik tempat user meng-klik pada lokasi peta
        $nX = isset($aVars["MAINMAP_x"]) ? intval($aVars["MAINMAP_x"]) : $fW / 2.0;
        $nY = isset($aVars["MAINMAP_y"]) ? intval($aVars["MAINMAP_y"]) : $fW / 2.0;
        if (isset($aVars["MAINMAP_x"]) && isset($aVars["MAINMAP_y"])) {
            $oPixelPos = ms_newpointobj();
            $oPixelPos->setxy($nX, $nY);
            $oGeoExt = ms_newrectobj();
            $oGeoExt->setextent($fMinX, $fMinY, $fMaxX, $fMaxY);
            //ubah skala peta, dengan method zoompoint atau setextent
            if ($aVars["CMD"] == "ZOOM_IN") {
                $GLOBALS["goMap"]->zoompoint(2, $oPixelPos, $fW, $fH, $oGeoExt);
            } else {
                if ($aVars["CMD"] == "ZOOM_OUT") {
                    $GLOBALS["goMap"]->zoompoint(-2, $oPixelPos, $fW, $fH, $oGeoExt);
                } else {
                    if ($aVars["CMD"] == "RECENTER") {
                        $GLOBALS["goMap"]->zoompoint(1, $oPixelPos, $fW, $fH, $oGeoExt);
                    } else {
                        if ($aVars["CMD"] == "ZOOM_ALL") {
                            $GLOBALS["goMap"]->setextent($GLOBALS["gfMinX"], $GLOBALS["gfMinY"], $GLOBALS["gfMaxX"], $GLOBALS["gfMaxY"]);
                        } else {
                            if ($aVars["CMD"] == "QUERY") {
                                $nGeoX = Pix2Geo($nX, 0, $fW, $fMinX, $fMaxX, 0);
                                $nGeoY = Pix2Geo($nY, 0, $fH, $fMinY, $fMaxY, 1);
                                $oGeo = ms_newPointObj();
                                $oGeo->setXY($nGeoX, $nGeoY);
                                // Simbol '@' digunakan supaya tidak muncul pesan peringatan
                                // ketika objek tidak ditemukan
                                @$GLOBALS["goMap"]->queryByPoint($oGeo, MS_SINGLE, -1);
                                $GLOBALS["gShowQueryResults"] = TRUE;
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (isset($aVars["KEYMAP_x"]) && isset($aVars["KEYMAP_y"])) {
            $oRefExt = $GLOBALS["goMap"]->reference->extent;
            $nX = intval($aVars["KEYMAP_x"]);
            $nY = intval($aVars["KEYMAP_y"]);
            $fWidthPix = doubleval($GLOBALS["goMap"]->reference->width);
            $fHeightPix = doubleval($GLOBALS["goMap"]->reference->height);
            $nGeoX = Pix2Geo($nX, 0, $fWidthPix, $oRefExt->minx, $oRefExt->maxx, 0);
            $nGeoY = Pix2Geo($nY, 0, $fHeightPix, $oRefExt->miny, $oRefExt->maxy, 1);
            $fDeltaX = ($fMaxX - $fMinX) / 2.0;
            $fDeltaY = ($fMaxY - $fMinY) / 2.0;
            $GLOBALS["goMap"]->setextent($nGeoX - $fDeltaX, $nGeoY - $fDeltaY, $nGeoX + $fDeltaX, $nGeoY + $fDeltaY);
        }
    }
}
Ejemplo n.º 15
0
if ($szUnits == "default") {
    $oMap->scalebar->set("units", $oMap->units);
} else {
    $oMap->scalebar->set("units", $_UNITS[$szUnits]);
}
$oMap->scalebar->outlinecolor->setRGB(0, 0, 0);
$oMap->scalebar->set("status", MS_EMBED);
/**
 * Uncomment this to enable debug
 */
//$oMap->setconfigoption('MS_ERRORFILE','/tmp/ms_tmp/wms2pdf.log');
/**
 * Mode setting
 */
//if($szMode == "scale"){
$oCenter = ms_newPointObj();
$oCenter->setXY($nMapWidth / 2, $nMapHeight / 2);
$oMap->zoomscale($szScale, $oCenter, $nMapWidth, $nMapHeight, $oMap->extent);
//}
/**
 * If document produced is not a pdf, we need to set the imageurl path.
 */
$oMap->web->set('imagepath', $_IMAGEPATH);
$oMap->web->set('imageurl', $_IMAGEURL);
/**
 * Map outputformat
 * Modification par MAT, sélection du format PNG pour permettre la transparence (OPACITY)
 * MOdification pour avoir un meilleur rendu cartographique lors de l'impression (Nicolas G.)
 */
$oMap->outputformat->setOption("QUALITY", "100");
$oMap->outputformat->set("transparent", "1");
Ejemplo n.º 16
0
    $focus["zoomin"] = "focus";
}
$ext = array($extminx, $extminy, $extmaxx, $extmaxy);
$e_extent = ms_newRectObj();
$e_extent->setextent($ext[0], $ext[1], $ext[2], $ext[3]);
// changement de taille d'image-carte en pixels
if (!isset($_REQUEST['size'])) {
    $sizex = $e_map->width;
    $sizey = $e_map->height;
} else {
    list($sizex, $sizey) = split('x', $_REQUEST['size']);
}
$sizecheck["{$sizex}x{$sizey}"] = " selected=\"selected\"";
$e_map->set('width', $sizex);
$e_map->set('height', $sizey);
$e_click = ms_newPointObj();
// objet de pointage
$e_click->setXY(floor($sizex / 2), floor($sizey / 2), 0);
// par d?faut, comme un clic au centre
// au cas ou fichier trk téléchargé
if (!empty($_FILES['trackfileimp']['name'])) {
    //debug("_FILES");
    echo import_track($_FILES['trackfileimp']['tmp_name'], "trk", "wgs84");
    unlink($_FILES['trackfileimp']['tmp_name']);
    // efface le fichier t?l?charg?
}
// recherche des villes correspondant aux crit?res
if (!empty($_REQUEST['ville'])) {
    $cities = $db->get_cities($_REQUEST['ville'], $deptsregion);
    // filtre rajout? pour les depts de la r?gion
    if (!$cities or count($cities) == 0) {
Ejemplo n.º 17
0
 /**
  * ZOOM MAP TO SPECIFIED SCALE
  */
 function zoom2scale()
 {
     $GEOEXT = $_SESSION["GEOEXT"];
     $geoext0 = ms_newrectObj();
     $geoext0->setExtent($GEOEXT["minx"], $GEOEXT["miny"], $GEOEXT["maxx"], $GEOEXT["maxy"]);
     // PREPARE MAP IMG
     $x_pix = $this->mapW / 2;
     $y_pix = $this->mapH / 2;
     $xy_pix = ms_newPointObj();
     $xy_pix->setXY($x_pix, $y_pix);
     $this->map->zoomscale($this->scale, $xy_pix, $this->mapW, $this->mapH, $geoext0);
     PMCommon::freeMsObj($xy_pix);
 }
Ejemplo n.º 18
0
 function redesenhaEntorno()
 {
     $nomes = nomeRandomico();
     $this->mapa->prepareimage();
     $e = $this->mapa->extent;
     $w = $this->mapa->width;
     $h = $this->mapa->height;
     $s = $this->mapa->scaledenom;
     $this->mapa = desligamargem($this->mapa);
     $pt = ms_newPointObj();
     //desenha o leste
     $pt->setXY($w + $w / 2, $h / 2);
     $this->mapa->zoompoint(0, $pt, $w, $h, $e);
     $nomeL = gravaImagemMapa($this->mapa);
     //desenha o oeste
     $pt->setXY(0 - $w / 2, $h / 2);
     $this->mapa->zoomscale($s * 2, $pt, $w, $h, $e);
     $nomeO = gravaImagemMapa();
     //desenha o norte
     $pt->setXY($w / 2, 0 - $h);
     $this->mapa->zoomscale($s * 2, $pt, $w, $h, $e);
     $nomeN = gravaImagemMapa();
     //desenha o sul
     $pt->setXY($w / 2, $h * 2);
     $this->mapa->zoomscale($s * 2, $pt, $w, $h, $e);
     $nomeS = gravaImagemMapa();
     return "var imagens=['" . $nomeL["url"] . "','" . $nomeO["url"] . "','" . $nomeN["url"] . "','" . $nomeS["url"] . "'];";
 }
Ejemplo n.º 19
0
 function rainfallMap()
 {
     global $rootpath, $basins, $mapscript;
     $map = ms_newMapObj("{$rootpath}/data/gis/squaw.map");
     $map->set("width", 200);
     $map->set("height", 300);
     $map->setextent(420000.0, 4645000.0, 451000.0, 4686000.0);
     $img = $map->prepareImage();
     $background = $map->getLayerByName("background");
     $background->set("status", MS_ON);
     $background->draw($img);
     $counties = $map->getLayerByName("iacounties");
     $counties->set("status", MS_ON);
     $counties->draw($img);
     $basin = $map->getLayerByName("squaw_basin");
     $basin->set("status", MS_ON);
     $basin->draw($img);
     $b = $map->getLayerByName("basins");
     foreach ($this->totprec as $id => $rain) {
         $pt = ms_newPointObj();
         $pt->setXY($basins[$id]["utm_x"], $basins[$id]["utm_y"]);
         $pt->draw($map, $b, $img, 0, $rain);
         $pt->free();
     }
     $map->drawLabelCache($img);
     $url = $img->saveWebImage();
     return $url;
 }