コード例 #1
0
ファイル: markupeditor.php プロジェクト: kanbang/Colt
 function AddPoint()
 {
     $geometryFactory = new MgGeometryFactory();
     $agfWriter = new MgAgfReaderWriter();
     $vertices = explode(',', $this->args['GEOMETRY']);
     $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[0], (double) $vertices[1]);
     $point = $geometryFactory->CreatePoint($coord);
     $trans = $this->GetTransform();
     if (null != $trans) {
         $point = $point->Transform($trans);
     }
     $byteReader = $agfWriter->Write($point);
     $propertyValues = new MgPropertyCollection();
     $propertyValues->Add(new MgStringProperty('Text', $this->args['TEXT']));
     $propertyValues->Add(new MgGeometryProperty('Geometry', $byteReader));
     $this->InsertMarkupFeature($propertyValues);
 }
コード例 #2
0
ファイル: createSdf.php プロジェクト: kanbang/Colt
$wkt = new MgWktReaderWriter();
$agf = new MgAgfReaderWriter();
$fact = new MgGeometryFactory();
echo "Created wkt/agf\n";
$count = 100;
$i = 0;
for ($i = 1; $i <= $count; $i++) {
    $bufferProps = new MgPropertyCollection();
    $nameProp = new MgStringProperty("NAME", "NewName_" . $i);
    $bufferProps->Add($nameProp);
    $x = 120 + $i / $count;
    $y = 100 + $i / $count;
    //$wktText = "POLYGON ((20 20, 20 100, {$x} {$y}, 140 20, 20 20))";
    //$geom = $wkt->Read($wktText);
    $coord = $fact->CreateCoordinateXY($x, $y);
    $geom = $fact->CreatePoint($coord);
    $geomReader = $agf->Write($geom);
    $geomProp = new MgGeometryProperty("GEOM", $geomReader);
    $bufferProps->Add($geomProp);
    $batchProp->Add($bufferProps);
}
echo "Created geometries via wkt\n";
$cmd = new MgInsertFeatures("Buffer", $batchProp);
$cmdColl = new MgFeatureCommandCollection();
$cmdColl->Add($cmd);
try {
    $svc->CreateFeatureSource($id, $params);
    $startTime = microtime(true);
    $props = $svc->UpdateFeatures($id, $cmdColl, false);
    $endTime = microtime(true);
    $diffTime = $endTime - $startTime;
コード例 #3
0
ファイル: findaddress.php プロジェクト: kanbang/Colt
            CreateAddressMarkerFeatureSource($featureService, $addressMarkerDataResId);
            $addressLayer = CreateAddressMarkerLayer($resourceService, $addressMarkerDataResId, $mgSessionId);
            $map->GetLayers()->Insert(0, $addressLayer);
        } else {
            if ($addressLayer->GetVisible()) {
                // If the layer exists and is visible, then display the
                // previous results.
                EmitAddressResults($featureService, $addressMarkerDataResId, $mgSessionId);
            }
        }
        // Insert the results of the Geo-Code into the temporary
        // feature source and ensure the address marker layer
        // is visible.
        $geometryReaderWriter = new MgAgfReaderWriter();
        $geometryFactory = new MgGeometryFactory();
        $addrPoint = $geometryFactory->CreatePoint($geometryFactory->CreateCoordinateXY((double) $long, (double) $lat));
        $properties = new MgPropertyCollection();
        $properties->Add(new MgStringProperty('Address', $address1));
        $properties->Add(new MgGeometryProperty('Location', $geometryReaderWriter->Write($addrPoint)));
        $commands = new MgFeatureCommandCollection();
        $commands->Add(new MgInsertFeatures('AddressMarker', $properties));
        $featureService->UpdateFeatures($addressMarkerDataResId, $commands, false);
        $addressLayer->SetVisible(true);
        $addressLayer->ForceRefresh();
        $map->Save($resourceService);
        $success = true;
    } else {
        echo '<tr><td>Address not found: ' . $address . '<hr></td></tr>';
        $success = false;
    }
} catch (MgException $e) {