$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; $reader = $props->GetItem(0)->GetValue(); while ($reader->ReadNext() == true) { $key = $reader->GetInt32("KEY"); }
$geometryProperty->SetGeometryTypes(MgFeatureGeometricType::Surface); // Add the geometry property to the class definition $classDefinition->GetProperties()->Add($geometryProperty); // Create a feature schema $featureSchema = new MgFeatureSchema("SHP_Schema", "Line schema"); // Add the feature schema to the class definition $featureSchema->GetClasses()->Add($classDefinition); // Create the feature source $wkt = $map->GetMapSRS(); $sdfParams = new MgCreateSdfParams("spatial context", $wkt, $featureSchema); $featureService->CreateFeatureSource($resourceIdentifier, $sdfParams); } // Add the line to the feature source $batchPropertyCollection = new MgBatchPropertyCollection(); $propertyCollection = MakeLine("Line A", $x0, $y0, $x1, $y1); $batchPropertyCollection->Add($propertyCollection); // Add the batch property collection to the feature source $cmd = new MgInsertFeatures($layerName, $batchPropertyCollection); $featureCommandCollection = new MgFeatureCommandCollection(); $featureCommandCollection->Add($cmd); // Execute the "add" commands $featureService->UpdateFeatures($resourceIdentifier, $featureCommandCollection, false); //---------------------------------------------------// $layerExists = DoesLayerExist($layerName, $map); if (!$layerExists) { // Create a new layer which uses that feature source // Create a line rule to stylize the lines $ruleLegendLabel = 'Lines Rule'; $filter = ''; $color = 'FF0000FF'; $factory = new LayerDefinitionFactory();
public static function ParseMultiFeatureDocument($app, $classDef, $doc, $featureNodeName = "Feature", $propertyNodeName = "Property") { $batchProps = new MgBatchPropertyCollection(); $featureNodes = $doc->getElementsByTagName($featureNodeName); $wktRw = new MgWktReaderWriter(); $agfRw = new MgAgfReaderWriter(); $classProps = $classDef->GetProperties(); for ($i = 0; $i < $featureNodes->length; $i++) { $propNodes = $featureNodes->item($i)->getElementsByTagName($propertyNodeName); $props = MgUtils::ParseFeatureNode($app, $propNodes, $agfRw, $wktRw, $classProps); $batchProps->Add($props); } return $batchProps; }