public function testToString()
 {
     $decoder = new gisconverter\WKT();
     $geom = $decoder->geomFromText('POINT(10 10)');
     $this->assertEquals($geom->toWKT(), (string) $geom);
     $geom = $decoder->geomFromText(' POINT  ( 10  10 ) ');
     $this->assertEquals($geom->toWKT(), (string) $geom);
 }
Example #2
0
 protected function _itemFromRow(Syj_Model_Path $item, Zend_Db_Table_Row $row)
 {
     $decoder = new gisconverter\WKT();
     $geom = $decoder->geomFromText($row->wkt);
     $item->setId($row->id)->setGeom($geom)->setTitle($row->title)->setUrlComp($row->urlcomp)->setCreatorIp($row->creator_ip);
     if (!$item->getCreator()) {
         $user = new Syj_Model_User();
         $userMapper = new Syj_Model_UserMapper();
         if ($userMapper->find($row->creator, $user)) {
             $item->setCreator($user);
         }
     }
     return $item;
 }
Example #3
0
 /**
  * @expectedException gisconverter\Unimplemented
  */
 public function invalidConversion3()
 {
     $decoder = new gisconverter\WKT();
     $geom = $decoder->geomFromText('LINESTRING(3.5 5.6,4.8 10.5,10 10)');
     $geom->toGPX('wpt');
 }
Example #4
0
function wkt_to_gpx($text)
{
    $decoder = new gisconverter\WKT();
    return $decoder->geomFromText($text)->toGPX();
}
Example #5
0
function exportaGeojson()
{
    global $oMap, $arq, $fileName, $versao, $ows_geomtype;
    include "pacotes/gisconverter/gisconverter.php";
    $decoder = new gisconverter\WKT();
    $layer = $oMap->getlayer(0);
    $items = pegaItens($layer, $oMap);
    $layer->querybyrect($oMap->extent);
    $layer->open();
    $res_count = $layer->getNumresults();
    $linhas = array();
    $features = array();
    for ($i = 0; $i < $res_count; $i++) {
        if ($versao >= 6) {
            $shape = $layer->getShape($layer->getResult($i));
        } else {
            $shape = $layer->getFeature($layer->getResult($i)->shapeindex);
        }
        $propriedades = array();
        foreach ($items as $item) {
            $v = trim($shape->values[$item]);
            if (is_string($v)) {
                $v = '"' . converteenc($v) . '"';
            }
            $propriedades[] = array($item => $v);
        }
        $wkt = $shape->towkt();
        $features[] = array("type" => "Feature", "properties" => $propriedades, "geometry" => json_decode($decoder->geomFromText($wkt)->toGeoJSON()));
    }
    $n[] = array("type" => "FeatureCollection", "features" => $features);
    $contents = json_encode($n[0]);
    $contents = str_replace('\\"', '', $contents);
    file_put_contents($arq . ".json", $contents);
    ob_clean();
    header("Content-type: application/json; subtype=geojson");
    echo $contents;
    exit;
}