Example #1
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);
}
Example #2
0
 /* if extending the current selection */
 $bExtendSelection = isset($_REQUEST['extendselection']) && strcasecmp($_REQUEST['extendselection'], 'true') == 0;
 if ($bExtendSelection) {
     $aLayerSelections = array();
     $selection->Open($resourceService, $mapName);
     $aLayers = selectionToArray($selection, array());
 }
 $bComputedProperties = isset($_REQUEST['computed']) && strcasecmp($_REQUEST['computed'], 'true') == 0;
 $bQueryHiddenLayers = isset($_REQUEST['queryHiddenLayers']) && strcasecmp($_REQUEST['queryHiddenLayers'], 'true') == 0;
 /*holds selection array*/
 $properties = NULL;
 $properties->layers = array();
 /* Get the map SRS - we use this to convert distances */
 $srsFactory = new MgCoordinateSystemFactory();
 //safely get an SRS ... (in Utilities)
 $srsDefMap = GetMapSRS($map);
 $srsMap = $srsFactory->Create($srsDefMap);
 $mapLayers = $map->GetLayers();
 $bAllLayers = false;
 $nLayers = count($layers);
 if ($nLayers == 0) {
     $nLayers = $mapLayers->GetCount();
     $bAllLayers = true;
 }
 for ($i = 0; $i < $nLayers; $i++) {
     try {
         if (!$bAllLayers) {
             $layerObj = $mapLayers->GetItem($layers[$i]);
         } else {
             $layerObj = $mapLayers->GetItem($i);
         }
Example #3
0
 *****************************************************************************/
include 'Common.php';
include 'Utilities.php';
try {
    if (!isset($_REQUEST['session']) || !isset($_REQUEST['mapname']) || !isset($_REQUEST['x1']) || !isset($_REQUEST['y1']) || !isset($_REQUEST['x2']) || !isset($_REQUEST['y2'])) {
        echo "<Error>Arguments missing </Error>";
        exit;
    }
    $x1 = $_REQUEST['x1'];
    $y1 = $_REQUEST['y1'];
    $x2 = $_REQUEST['x2'];
    $y2 = $_REQUEST['y2'];
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    $srsFactory = new MgCoordinateSystemFactory();
    $srs = GetMapSRS($map);
    $srsMap = $srsFactory->Create($srs);
    $srsType = $srsMap->GetType();
    if ($srsType == MgCoordinateSystemType::Geographic) {
        $distance = $srsMap->MeasureGreatCircleDistance($x1, $y1, $x2, $y2);
    } else {
        $distance = $srsMap->MeasureEuclideanDistance($x1, $y1, $x2, $y2);
    }
    $distance = $srsMap->ConvertCoordinateSystemUnitsToMeters($distance);
    header('Content-type: text/x-json');
    header('X-JSON: true');
    echo "{distance:{$distance}}";
    exit;
} catch (MgException $e) {
    echo "last error";
    echo "ERROR: " . $e->GetMessage() . "\n";