コード例 #1
0
ファイル: GeneratePicture.php プロジェクト: kanbang/Colt
function CreatePolygon($coordinates)
{
    $geometryFactory = new MgGeometryFactory();
    $coordinateCollection = new MgCoordinateCollection();
    $linearRingCollection = new MgLinearRingCollection();
    for ($index = 0; $index < count($coordinates); ++$index) {
        $coordinate = $geometryFactory->CreateCoordinateXY(ParseLocaleDouble($coordinates[$index]), ParseLocaleDouble($coordinates[++$index]));
        $coordinateCollection->Add($coordinate);
    }
    $coordinateCollection->Add($geometryFactory->CreateCoordinateXY(ParseLocaleDouble($coordinates[0]), ParseLocaleDouble($coordinates[1])));
    $linearRingCollection = $geometryFactory->CreateLinearRing($coordinateCollection);
    $captureBox = $geometryFactory->CreatePolygon($linearRingCollection, null);
    return $captureBox;
}
コード例 #2
0
ファイル: query.php プロジェクト: kanbang/Colt
 private function CreatePolygonFromGeomText($geomText)
 {
     $geometryFactory = new MgGeometryFactory();
     $vertices = explode(',', $geomText);
     $count = $vertices[0];
     $coords = new MgCoordinateCollection();
     for ($i = 0; $i < $count; $i++) {
         $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[$i * 2 + 1], (double) $vertices[$i * 2 + 2]);
         $coords->Add($coord);
     }
     $linearRing = $geometryFactory->CreateLinearRing($coords);
     $polygon = $geometryFactory->CreatePolygon($linearRing, null);
     return $polygon;
 }
コード例 #3
0
ファイル: query.php プロジェクト: ranyaof/gismaster
    private function CreatePolygonFromGeomText($geomText)
    {
        $geometryFactory = new MgGeometryFactory();

        $vertices = explode(',', $geomText);
        $count = $vertices[0];

        $coords = new MgCoordinateCollection();
        for ($i = 0; $i < $count; $i++)
        {
            $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[($i * 2) + 1], (double) $vertices[($i * 2) + 2]);
            $coords->Add($coord);
        }

        //Some provider such as SQL Server Spatial, ODBC requires the polygon's start point must be the same as end point.
        if(($count>2) && (($coords->GetItem(0)->GetX() != $coords->GetItem($count-1)->GetX()) || ($coords->GetItem(0)->GetY() != $coords->GetItem($count-1)->GetY())))
        {
            $coord = $geometryFactory->CreateCoordinateXY($coords->GetItem(0)->GetX(), $coords->GetItem(0)->GetY());
            $coords->Add($coord);
        }

        $linearRing = $geometryFactory->CreateLinearRing($coords);
        $polygon = $geometryFactory->CreatePolygon($linearRing, null);

        return $polygon;
    }
コード例 #4
0
ファイル: markupeditor.php プロジェクト: kanbang/Colt
 function AddPolygon()
 {
     $geometryFactory = new MgGeometryFactory();
     $agfWriter = new MgAgfReaderWriter();
     $vertices = explode(',', $this->args['GEOMETRY']);
     $count = $vertices[0];
     $coords = new MgCoordinateCollection();
     for ($i = 0; $i < $count; $i++) {
         $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[$i * 2 + 1], (double) $vertices[$i * 2 + 2]);
         $coords->Add($coord);
     }
     // Add the first vertex to make the ring close
     if ($count > 2) {
         $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[1], (double) $vertices[2]);
         $coords->Add($coord);
     }
     $linearRing = $geometryFactory->CreateLinearRing($coords);
     $polygon = $geometryFactory->CreatePolygon($linearRing, null);
     $trans = $this->GetTransform();
     if (null != $trans) {
         $polygon = $polygon->Transform($trans);
     }
     $byteReader = $agfWriter->Write($polygon);
     $propertyValues = new MgPropertyCollection();
     $propertyValues->Add(new MgStringProperty('Text', $this->args['TEXT']));
     $propertyValues->Add(new MgGeometryProperty('Geometry', $byteReader));
     $this->InsertMarkupFeature($propertyValues);
 }