Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
 static function CreateMarkupSchema($geomType = -1)
 {
     $markupSchema = new MgFeatureSchema();
     $markupSchema->SetName('MarkupSchema');
     if ($geomType == -1) {
         $geomType = MgFeatureGeometricType::Point | MgFeatureGeometricType::Curve | MgFeatureGeometricType::Surface;
     }
     $markupSchema->GetClasses()->Add(MarkupSchemaFactory::CreateMarkupClass($geomType));
     return $markupSchema;
 }
Exemplo n.º 4
0
 function InitMarkupRegistry()
 {
     //NOTE: EnumerateResources does not work for session repositories. So to be able to "enumerate"
     //resources, we create a registry feature source that would store this information
     $this->markupRegistryId = new MgResourceIdentifier($this->GetResourceIdPrefix() . MarkupManager::MARKUP_REGISTRY_NAME . ".FeatureSource");
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     //Create the markup registry feature source if it doesn't already exist
     if (!$resourceService->ResourceExists($this->markupRegistryId)) {
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         //Markup Registry Feature Source Schema
         //
         //Default
         //  MarkupRegistry
         //    ResourceId (String, Identity, Not Null)
         //    LayerDefintion (String, Not Null)
         //    Name (String, Not Null)
         //    FdoProvider (String, Not Null)
         //    GeometryTypes (Int, Not Null)
         $markupRegSchema = new MgFeatureSchema("Default", "");
         $markupRegClass = new MgClassDefinition();
         $markupRegClass->SetName("MarkupRegistry");
         $markupRegId = new MgDataPropertyDefinition("ResourceId");
         $markupRegId->SetDataType(MgPropertyType::String);
         $markupRegId->SetLength(1024);
         $markupRegId->SetNullable(false);
         $layerDefId = new MgDataPropertyDefinition("LayerDefinition");
         $layerDefId->SetDataType(MgPropertyType::String);
         $layerDefId->SetLength(1024);
         $layerDefId->SetNullable(false);
         $markupRegName = new MgDataPropertyDefinition("Name");
         $markupRegName->SetDataType(MgPropertyType::String);
         $markupRegName->SetLength(512);
         $markupRegName->SetNullable(false);
         $fdoProvider = new MgDataPropertyDefinition("FdoProvider");
         $fdoProvider->SetDataType(MgPropertyType::String);
         $fdoProvider->SetLength(512);
         $fdoProvider->SetNullable(false);
         $geomTypes = new MgDataPropertyDefinition("GeometryTypes");
         $geomTypes->SetDataType(MgPropertyType::Int32);
         $geomTypes->SetNullable(false);
         $dataProps = $markupRegClass->GetProperties();
         $dataProps->Add($markupRegId);
         $dataProps->Add($layerDefId);
         $dataProps->Add($markupRegName);
         $dataProps->Add($fdoProvider);
         $dataProps->Add($geomTypes);
         $idProps = $markupRegClass->GetIdentityProperties();
         $idProps->Add($markupRegId);
         $classes = $markupRegSchema->GetClasses();
         $classes->Add($markupRegClass);
         $createSdf = new MgFileFeatureSourceParams("OSGeo.SDF", "Default", "", $markupRegSchema);
         $featureService->CreateFeatureSource($this->markupRegistryId, $createSdf);
     }
 }
Exemplo n.º 5
0
 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;
 }
 public function CreateFeatureSource($resId, $inputFormat)
 {
     //Check for unsupported representations
     $fmt = $this->ValidateRepresentation($inputFormat, array("xml", "json"));
     $sessionId = "";
     if ($resId->GetRepositoryType() == MgRepositoryType::Session) {
         $sessionId = $resId->GetRepositoryName();
     }
     $mimeType = $this->GetMimeTypeForFormat($fmt);
     $this->EnsureAuthenticationForSite($sessionId, false, $mimeType);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $site = $siteConn->GetSite();
     $this->VerifyWhitelist($resId->ToString(), $mimeType, "CREATEFEATURESOURCE", $fmt, $site, $this->userName);
     $this->EnsureAuthenticationForSite($sessionId);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
     if ($fmt == "json") {
         $body = $this->app->request->getBody();
         $json = json_decode($body);
         if ($json == NULL) {
             throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
         }
     } else {
         $body = $this->app->request->getBody();
         $jsonStr = MgUtils::Xml2Json($body);
         $json = json_decode($jsonStr);
     }
     if (!isset($json->FeatureSourceParams)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     $fsParams = $json->FeatureSourceParams;
     if (!isset($fsParams->File)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     if (!isset($fsParams->SpatialContext)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     if (!isset($fsParams->FeatureSchema)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     $mkParams = new MgFileFeatureSourceParams();
     if (isset($fsParams->File->Provider)) {
         $mkParams->SetProviderName($fsParams->File->Provider);
     }
     if (isset($fsParams->File->FileName)) {
         $mkParams->SetFileName($fsParams->File->FileName);
     }
     if (isset($fsParams->SpatialContext->Name)) {
         $mkParams->SetSpatialContextName($fsParams->SpatialContext->Name);
     }
     if (isset($fsParams->SpatialContext->Description)) {
         $mkParams->SetSpatialContextDescription($fsParams->SpatialContext->Description);
     }
     if (isset($fsParams->SpatialContext->CoordinateSystem)) {
         $mkParams->SetCoordinateSystemWkt($fsParams->SpatialContext->CoordinateSystem);
     }
     if (isset($fsParams->SpatialContext->XYTolerance)) {
         $mkParams->SetXYTolerance($fsParams->SpatialContext->XYTolerance);
     }
     if (isset($fsParams->SpatialContext->ZTolerance)) {
         $mkParams->SetZTolerance($fsParams->SpatialContext->ZTolerance);
     }
     $mkSchema = $fsParams->FeatureSchema;
     $schema = new MgFeatureSchema();
     if (isset($mkSchema->Name)) {
         $schema->SetName($mkSchema->Name);
     }
     if (isset($mkSchema->Description)) {
         $schema->SetDescription($mkSchema->Description);
     }
     $classes = $schema->GetClasses();
     foreach ($mkSchema->ClassDefinition as $mkClass) {
         $cls = new MgClassDefinition();
         if (isset($mkClass->Name)) {
             $cls->SetName($mkClass->Name);
         }
         if (isset($mkClass->Description)) {
             $cls->SetDescription($mkClass->Description);
         }
         if (isset($mkClass->DefaultGeometryPropertyName)) {
             $cls->SetDefaultGeometryPropertyName($mkClass->DefaultGeometryPropertyName);
         }
         $clsProps = $cls->GetProperties();
         $idProps = $cls->GetIdentityProperties();
         foreach ($mkClass->PropertyDefinition as $propDef) {
             if (isset($propDef->PropertyType)) {
                 $mkProp = null;
                 switch ($propDef->PropertyType) {
                     case MgFeaturePropertyType::DataProperty:
                         $mkProp = new MgDataPropertyDefinition($propDef->Name);
                         if (isset($propDef->DataType)) {
                             $mkProp->SetDataType($propDef->DataType);
                         }
                         if (isset($propDef->Nullable)) {
                             $mkProp->SetNullable($propDef->Nullable);
                         }
                         if (isset($propDef->IsAutoGenerated)) {
                             $mkProp->SetAutoGeneration($propDef->IsAutoGenerated);
                         }
                         if (isset($propDef->DefaultValue)) {
                             $mkProp->SetDefaultValue($propDef->DefaultValue);
                         }
                         if (isset($propDef->Length)) {
                             $mkProp->SetLength($propDef->Length);
                         }
                         if (isset($propDef->Precision)) {
                             $mkProp->SetPrecision($propDef->Precision);
                         }
                         if (isset($propDef->Scale)) {
                             $mkProp->SetScale($propDef->Scale);
                         }
                         break;
                     case MgFeaturePropertyType::GeometricProperty:
                         $mkProp = new MgGeometricPropertyDefinition($propDef->Name);
                         if (isset($propDef->GeometryTypes)) {
                             $mkProp->SetGeometryTypes($propDef->GeometryTypes);
                         }
                         if (isset($propDef->HasElevation)) {
                             $mkProp->SetHasElevation($propDef->HasElevation);
                         }
                         if (isset($propDef->HasMeasure)) {
                             $mkProp->SetHasMeasure($propDef->HasMeasure);
                         }
                         if (isset($propDef->SpatialContextAssociation)) {
                             $mkProp->SetSpatialContextAssociation($propDef->SpatialContextAssociation);
                         }
                         break;
                     default:
                         throw new Exception($this->app->localizer->getText("E_UNSUPPORTED_PROPERTY_TYPE"));
                 }
                 if ($mkProp != null) {
                     if (isset($propDef->Description)) {
                         $mkProp->SetDescription($propDef->Description);
                     }
                     if (isset($propDef->ReadOnly)) {
                         $mkProp->SetReadOnly($propDef->ReadOnly);
                     }
                     $clsProps->Add($mkProp);
                     if (isset($propDef->IsIdentity) && $propDef->IsIdentity == true) {
                         $idProps->Add($mkProp);
                     }
                 }
             }
         }
         if (isset($mkClass->DefaultGeometryPropertyName)) {
             $cls->SetDefaultGeometryPropertyName($mkClass->DefaultGeometryPropertyName);
         }
         $classes->Add($cls);
     }
     $mkParams->SetFeatureSchema($schema);
     try {
         $featSvc->CreateFeatureSource($resId, $mkParams);
     } catch (MgException $ex) {
         $this->OnException($ex, $mimeType);
     }
 }
Exemplo n.º 7
0
     $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");
     // 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);
Exemplo n.º 8
0
$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';
$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
Exemplo n.º 9
0
}
try {
    Utils::MapAgentInit(WEBCONFIGINI);
    $site = new MgSiteConnection();
    $cred = new MgUserInformation();
    $cred->SetMgUsernamePassword("Administrator", "admin");
    $cred->SetLocale("en");
    $site->Open($cred);
    $fsvc = $site->CreateService(MgServiceType::FeatureService);
    $rsvc = $site->CreateService(MgServiceType::ResourceService);
    $wkt = "LOCALCS[\"Non-Earth (Meter)\",LOCAL_DATUM[\"Local Datum\",0],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
    $featureName = 'Library://TrevorWekel/NewSdf.FeatureSource';
    $id = new MgResourceIdentifier($featureName);
    $intFeature = new IntKeyFeature();
    $stringFeature = new StringKeyFeature();
    $schema = new MgFeatureSchema("TestSchema", "Temporary test schema");
    $schema->GetClasses()->Add($intFeature->ClassDefinition());
    $params = new MgCreateSdfParams("ArbitraryXY", $wkt, $schema);
    $src = new MgByteSource("NewSdf.MapDefinition");
    $rid = new MgResourceIdentifier("Library://TrevorWekel/NewSdf.MapDefinition");
    $rsvc->SetResource($rid, $src->GetReader(), null);
    $src = new MgByteSource("NewSdfInt.LayerDefinition");
    $rid = new MgResourceIdentifier("Library://TrevorWekel/NewSdfInt.LayerDefinition");
    $rsvc->SetResource($rid, $src->GetReader(), null);
    $src = new MgByteSource("NewSdfString.LayerDefinition");
    $rid = new MgResourceIdentifier("Library://TrevorWekel/NewSdfString.LayerDefinition");
    $rsvc->SetResource($rid, $src->GetReader(), null);
    echo "Deleting existing feature source\n";
    $rsvc->DeleteResource($id);
    echo "Creating new feature source\n";
    $fsvc->CreateFeatureSource($id, $params);
Exemplo n.º 10
0
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);
}
Exemplo n.º 11
0
 $resSvc->SetResource($res2, $br2, null);
 //Enable writeable parcels
 $parcelsId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/Parcels.FeatureSource");
 $writeParcelsId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/Parcels_Writeable.FeatureSource");
 if ($resSvc->ResourceExists($parcelsId)) {
     $resSvc->CopyResource($parcelsId, $writeParcelsId, true);
     $bsWriteable = new MgByteSource(dirname(__FILE__) . "/Parcels_Writeable.FeatureSource.xml");
     $brWriteable = $bsWriteable->GetReader();
     $resSvc->SetResource($writeParcelsId, $brWriteable, null);
 }
 //Set up comments data store
 $commentsId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/ParcelComments.FeatureSource");
 if ($resSvc->ResourceExists($commentsId)) {
     $resSvc->DeleteResource($commentsId);
 }
 $schema = new MgFeatureSchema("Default", "Default schema");
 $clsDef = new MgClassDefinition();
 $clsDef->SetName("ParcelComments");
 $props = $clsDef->GetProperties();
 $idProps = $clsDef->GetIdentityProperties();
 $id = new MgDataPropertyDefinition("ID");
 $id->SetDataType(MgPropertyType::Int32);
 $id->SetNullable(false);
 $id->SetAutoGeneration(true);
 $pid = new MgDataPropertyDefinition("ParcelID");
 $pid->SetDataType(MgPropertyType::Int32);
 $pid->SetNullable(false);
 $pid->SetLength(255);
 $name = new MgDataPropertyDefinition("Name");
 $name->SetDataType(MgPropertyType::String);
 $name->SetNullable(true);