function CreateFeatureSource($map, $dataSourceId, $featureName, $featureService, $geomType, $schema = "") { //create feature source $classDef = new MgClassDefinition(); $classDef->SetName($featureName); $classDef->SetDescription($featureName . " feature layer"); $classDef->SetDefaultGeometryPropertyName("GEOM"); //Set KEY property $prop = new MgDataPropertyDefinition("KEY"); $prop->SetDataType(MgPropertyType::Int32); $prop->SetAutoGeneration(true); $prop->SetReadOnly(true); $classDef->GetIdentityProperties()->Add($prop); $classDef->GetProperties()->Add($prop); $prop = new MgGeometricPropertyDefinition("GEOM"); $prop->SetGeometryTypes($geomType); $classDef->GetProperties()->Add($prop); //Create the schema if ($schema == "") { $schema = "DrawToolSchema"; } $schema = new MgFeatureSchema($schema, "Temporary draw layer schema"); $schema->GetClasses()->Add($classDef); //finally, creation of the feature source $params = new MgCreateSdfParams("LatLong", GetMapSRS($map), $schema); $featureService->CreateFeatureSource($dataSourceId, $params); }
function CreateParcelMarkerFeatureSource($featureService, $wkt, $parcelMarkerDataResId) { $parcelClass = new MgClassDefinition(); $parcelClass->SetName('ParcelMarkerClass'); $properties = $parcelClass->GetProperties(); $idProperty = new MgDataPropertyDefinition('ID'); $idProperty->SetDataType(MgPropertyType::Int32); $idProperty->SetReadOnly(true); $idProperty->SetNullable(false); $idProperty->SetAutoGeneration(true); $properties->Add($idProperty); $pointProperty = new MgGeometricPropertyDefinition('ParcelLocation'); $pointProperty->SetGeometryTypes(MgGeometryType::Point); $pointProperty->SetHasElevation(false); $pointProperty->SetHasMeasure(false); $pointProperty->SetReadOnly(false); $pointProperty->SetSpatialContextAssociation('defaultSrs'); $properties->Add($pointProperty); $idProperties = $parcelClass->GetIdentityProperties(); $idProperties->Add($idProperty); $parcelClass->SetDefaultGeometryPropertyName('ParcelLocation'); $parcelSchema = new MgFeatureSchema('ParcelLayerSchema', 'temporary schema to hold parcel markers'); $parcelSchema->GetClasses()->Add($parcelClass); $sdfParams = new MgCreateSdfParams('defaultSrs', $wkt, $parcelSchema); $featureService->CreateFeatureSource($parcelMarkerDataResId, $sdfParams); }
function CreateAddressMarkerFeatureSource($featureService, $addressMarkerDataResId) { $ll84Wkt = 'GEOGCS["WGS84 Lat/Long\'s, Degrees, -180 ==> +180",DATUM["D_WGS_1984",SPHEROID["World_Geodetic_System_of_1984",6378137,298.257222932867]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'; $addressClass = new MgClassDefinition(); $addressClass->SetName('AddressMarker'); $properties = $addressClass->GetProperties(); $idProperty = new MgDataPropertyDefinition('ID'); $idProperty->SetDataType(MgPropertyType::Int32); $idProperty->SetReadOnly(true); $idProperty->SetNullable(false); $idProperty->SetAutoGeneration(true); $properties->Add($idProperty); $addressProperty = new MgDataPropertyDefinition('Address'); $addressProperty->SetDataType(MgPropertyType::String); $addressProperty->SetLength(512); $properties->Add($addressProperty); $locationProperty = new MgGeometricPropertyDefinition('Location'); $locationProperty->SetGeometryTypes(MgGeometryType::Point); $locationProperty->SetHasElevation(false); $locationProperty->SetHasMeasure(false); $locationProperty->SetReadOnly(false); $locationProperty->SetSpatialContextAssociation('LL84'); $properties->Add($locationProperty); $idProperties = $addressClass->GetIdentityProperties(); $idProperties->Add($idProperty); $addressClass->SetDefaultGeometryPropertyName('Location'); $addressSchema = new MgFeatureSchema(); $addressSchema->SetName('AddressMarkerSchema'); $addressSchema->GetClasses()->Add($addressClass); $sdfParams = new MgCreateSdfParams('LL84', $ll84Wkt, $addressSchema); $featureService->CreateFeatureSource($addressMarkerDataResId, $sdfParams); }
static function CreateIDProperty() { $idProperty = new MgDataPropertyDefinition('ID'); $idProperty->SetDataType(MgPropertyType::Int32); $idProperty->SetReadOnly(true); $idProperty->SetNullable(false); $idProperty->SetAutoGeneration(true); return $idProperty; }
private function CreateFilterSchema() { $filterSchema = new MgFeatureSchema(); $filterSchema->SetName('FilterSchema'); $filterClass = new MgClassDefinition(); $filterClass->SetName('Filter'); $properties = $filterClass->GetProperties(); $idProperty = new MgDataPropertyDefinition('ID'); $idProperty->SetDataType(MgPropertyType::Int32); $idProperty->SetReadOnly(true); $idProperty->SetNullable(false); $idProperty->SetAutoGeneration(true); $properties->Add($idProperty); $geometryProperty = new MgGeometricPropertyDefinition('Geometry'); $geometryProperty->SetGeometryTypes(MgFeatureGeometricType::Surface); $geometryProperty->SetHasElevation(false); $geometryProperty->SetHasMeasure(false); $geometryProperty->SetReadOnly(false); $geometryProperty->SetSpatialContextAssociation('MAPCS'); $properties->Add($geometryProperty); $filterClass->GetIdentityProperties()->Add($idProperty); $filterClass->SetDefaultGeometryPropertyName('Geometry'); $filterSchema->GetClasses()->Add($filterClass); return $filterSchema; }
$resourceIdentifier = new MgResourceIdentifier($featureSourceName); $featureSourceExists = DoesResourceExist($resourceIdentifier, $resourceService); if (!$featureSourceExists) { // Create a temporary feature source to draw the lines on // Create a feature class definition for the new feature // source $classDefinition = new MgClassDefinition(); $classDefinition->SetName("Lines"); $classDefinition->SetDescription("Lines to display."); $geometryPropertyName = "SHPGEOM"; $classDefinition->SetDefaultGeometryPropertyName($geometryPropertyName); // Create an identify property $identityProperty = new MgDataPropertyDefinition("KEY"); $identityProperty->SetDataType(MgPropertyType::Int32); $identityProperty->SetAutoGeneration(true); $identityProperty->SetReadOnly(true); // Add the identity property to the class definition $classDefinition->GetIdentityProperties()->Add($identityProperty); $classDefinition->GetProperties()->Add($identityProperty); // Create a name property $nameProperty = new MgDataPropertyDefinition("NAME"); $nameProperty->SetDataType(MgPropertyType::String); // Add the name property to the class definition $classDefinition->GetProperties()->Add($nameProperty); // 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");
} catch (MgException $exc) { echo $exc->GetExceptionMessage() . "\n"; echo $exc->GetDetails() . "\n"; return; } echo "Created Services\n"; // Create class definition for new feature class $classDef = new MgClassDefinition(); $classDef->SetName("Buffer"); $classDef->SetDescription("Feature class for buffer layer"); $classDef->SetDefaultGeometryPropertyName("GEOM"); // Set key property $prop = new MgDataPropertyDefinition("KEY"); $prop->SetDataType(MgPropertyType::Int32); $prop->SetAutoGeneration(true); $prop->SetReadOnly(true); $classDef->GetIdentityProperties()->Add($prop); $classDef->GetProperties()->Add($prop); $prop = new MgDataPropertyDefinition("NAME"); $prop->SetDataType(MgPropertyType::String); $classDef->GetProperties()->Add($prop); // Set geometry property $prop = new MgGeometricPropertyDefinition("GEOM"); $prop->SetGeometryTypes(MgFeatureGeometricType::Surface); $classDef->GetProperties()->Add($prop); $schema = new MgFeatureSchema("BufferSchema", "Temporary buffer schema"); $schema->GetClasses()->Add($classDef); $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';