Example #1
0
$wkt = "LOCALCS[\"Non-Earth (Meter)\",LOCAL_DATUM[\"Local Datum\",0],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
$params = new MgCreateSdfParams("ArbitraryXY", $wkt, $schema);
echo "Created sdfparams\n";
$layerName = 'Library://TrevorWekel/NewSdf.FeatureSource';
$id = new MgResourceIdentifier($layerName);
try {
    $svc->CreateFeatureSource($id, $params);
} catch (MgException $exc) {
    echo $exc->GetExceptionMessage() . "\n";
    echo $exc->GetDetails() . "\n";
    return;
}
echo "Created featuresource\n";
// We need to add some data to the sdf before using it.  The spatial context
// reader must have an extent.
$batchProp = new MgBatchPropertyCollection();
$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);
Example #2
0
     // Create a geometry property
     $geometryProperty = new MgGeometricPropertyDefinition($geometryPropertyName);
     $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 = '';
Example #3
0
 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;
 }