function GetSelectionXML() { $json = new Services_JSON(); $resourceService = $this->site->CreateService(MgServiceType::ResourceService); $featureService = $this->site->CreateService(MgServiceType::FeatureService); $map = new MgMap(); $map->Open($resourceService, $this->args['MAPNAME']); $layer = $map->GetLayers()->GetItem($this->args['LAYERNAME']); $resId = new MgResourceIdentifier($layer->GetFeatureSourceId()); $featureClass = $layer->GetFeatureClassName(); $schemaAndClass = explode(":", $featureClass); $classDef = $featureService->GetClassDefinition($resId, $schemaAndClass[0], $schemaAndClass[1]); $properties = new MgPropertyCollection(); $idList = $json->decode($this->args['IDLIST']); foreach ($idList as $key => $value) { switch ($classDef->GetProperties()->GetItem($key)->GetDataType()) { case MgPropertyType::Boolean: $properties->Add(new MgBooleanProperty($key, $value)); break; case MgPropertyType::Byte: $properties->Add(new MgByteProperty($key, $value)); break; case MgPropertyType::Single: $properties->Add(new MgSingleProperty($key, $value)); break; case MgPropertyType::Double: $properties->Add(new MgDoubleProperty($key, $value)); break; case MgPropertyType::Int16: $properties->Add(new MgInt16Property($key, $value)); break; case MgPropertyType::Int32: $properties->Add(new MgInt32Property($key, $value)); break; case MgPropertyType::Int64: $properties->Add(new MgInt64Property($key, $value)); break; case MgPropertyType::String: $properties->Add(new MgStringProperty($key, $value)); break; case MgPropertyType::DateTime: $properties->Add(new MgDateTimeProperty($key, $value)); break; case MgPropertyType::Null: case MgPropertyType::Blob: case MgPropertyType::Clob: case MgPropertyType::Feature: case MgPropertyType::Geometry: case MgPropertyType::Raster: break; } } $selection = new MgSelection($map); $selection->AddFeatureIds($layer, $featureClass, $properties); return $selection->ToXml(); }
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); $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);
function MakeLine($name, $x0, $y0, $x1, $y1) { $propertyCollection = new MgPropertyCollection(); $nameProperty = new MgStringProperty("NAME", $name); $propertyCollection->Add($nameProperty); $wktReaderWriter = new MgWktReaderWriter(); $agfReaderWriter = new MgAgfReaderWriter(); $geometry = $wktReaderWriter->Read("LINESTRING XY ({$x0} {$y0}, {$x1} {$y1})"); $geometryByteReader = $agfReaderWriter->Write($geometry); $geometryProperty = new MgGeometryProperty("SHPGEOM", $geometryByteReader); $propertyCollection->Add($geometryProperty); return $propertyCollection; }
function UploadMarkup() { $locale = "en"; if (array_key_exists("LOCALE", $this->args)) { $locale = $this->args["LOCALE"]; } $uploadFileParts = pathinfo($_FILES["UPLOADFILE"]["name"]); $fdoProvider = $this->GetProviderFromExtension($uploadFileParts["extension"]); if ($fdoProvider == null) { throw new Exception(GetLocalizedString("REDLINEUPLOADUNKNOWNPROVIDER", $locale)); } $resourceService = $this->site->CreateService(MgServiceType::ResourceService); $featureService = $this->site->CreateService(MgServiceType::FeatureService); $bs = new MgByteSource($_FILES["UPLOADFILE"]["tmp_name"]); $br = $bs->GetReader(); //Use file name to drive all parameters $baseName = $uploadFileParts["filename"]; $this->UniqueMarkupName($baseName); //Guard against potential duplicates $ext = $uploadFileParts["extension"]; $markupLayerResId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $baseName . ".LayerDefinition"); $markupFsId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $baseName . '.FeatureSource'); //Set up feature source document $dataName = $baseName . "." . $ext; $fileParam = "File"; $shpFileParts = array(); if (strcmp($fdoProvider, "OSGeo.SHP") == 0) { $dataName = null; $fileParam = "DefaultFileLocation"; $zip = new ZipArchive(); if ($zip->open($_FILES["UPLOADFILE"]["tmp_name"]) === TRUE) { for ($i = 0; $i < $zip->numFiles; $i++) { $stat = $zip->statIndex($i); $filePath = tempnam(sys_get_temp_dir(), "upload"); //Dump to temp file file_put_contents($filePath, $zip->getFromIndex($i)); //Stash for later upload and cleanup $entry = $stat["name"]; $shpFileParts[$entry] = $filePath; if (substr($entry, strlen($entry) - strlen(".shp")) == ".shp") { $dataName = $entry; } } //Abort if we can't find a .shp file. This is not a valid zip file if ($dataName == null) { throw new Exception(GetLocalizedString("REDLINEUPLOADSHPZIPERROR", $locale)); } } else { throw new Exception(GetLocalizedString("REDLINEUPLOADSHPZIPERROR", $locale)); } } $extraXml = ""; if (strcmp($fdoProvider, "OSGeo.SDF") == 0) { //Need to set ReadOnly = false for SDF $extraXml = "<Parameter><Name>ReadOnly</Name><Value>FALSE</Value></Parameter>"; } $fsXml = sprintf(file_get_contents("templates/markupfeaturesource.xml"), $fdoProvider, $fileParam, $dataName, $extraXml); $bs2 = new MgByteSource($fsXml, strlen($fsXml)); $resourceService->SetResource($markupFsId, $bs2->GetReader(), null); if (count($shpFileParts) > 0) { foreach ($shpFileParts as $name => $path) { $bs3 = new MgByteSource($path); $resourceService->SetResourceData($markupFsId, $name, "File", $bs3->GetReader()); //Cleanup unlink($path); } } else { //Not a SHP file $resourceService->SetResourceData($markupFsId, $dataName, "File", $bs->GetReader()); } //Query the geometry types $schemas = $featureService->DescribeSchema($markupFsId, "", null); $schema = $schemas->GetItem(0); $classes = $schema->GetClasses(); $klass = $classes->GetItem(0); $geomProp = $klass->GetDefaultGeometryPropertyName(); $clsProps = $klass->GetProperties(); $className = $schema->GetName() . ":" . $klass->GetName(); $geomTypes = -1; if ($clsProps->IndexOf($geomProp) >= 0) { $geom = $clsProps->GetItem($geomProp); $geomTypes = $geom->GetGeometryTypes(); //Since we're here. Validate the schema requirements. If this was created by this widget previously //it will be valid $idProps = $klass->GetIdentityProperties(); if ($idProps->GetCount() != 1) { throw new Exception(GetLocalizedString("REDLINEUPLOADINVALIDSCHEMA", $locale)); } else { //Must be auto-generated (implying numerical as well) $keyProp = $idProps->GetItem(0); if (!$keyProp->IsAutoGenerated()) { throw new Exception(GetLocalizedString("REDLINEUPLOADINVALIDSCHEMA", $locale)); } } if ($clsProps->IndexOf("Text") < 0) { throw new Exception(GetLocalizedString("REDLINEUPLOADINVALIDSCHEMA", $locale)); } } else { throw new Exception(GetLocalizedString("REDLINEUPLOADINVALIDSCHEMA", $locale)); } //Set up default style args $this->args["MARKUPNAME"] = $baseName; $this->args["MARKERCOLOR"] = DefaultStyle::MARKER_COLOR; $this->args["MARKERTYPE"] = DefaultStyle::MARKER_TYPE; $this->args["MARKERSIZEUNITS"] = DefaultStyle::MARKER_SIZE_UNITS; $this->args["MARKERSIZE"] = DefaultStyle::MARKER_SIZE; $this->args["LINECOLOR"] = DefaultStyle::LINE_COLOR; $this->args["LINEPATTERN"] = DefaultStyle::LINE_PATTERN; $this->args["LINESIZEUNITS"] = DefaultStyle::LINE_SIZE_UNITS; $this->args["LINETHICKNESS"] = DefaultStyle::LINE_THICKNESS; $this->args["FILLPATTERN"] = DefaultStyle::FILL_PATTERN; $this->args["FILLTRANSPARENCY"] = DefaultStyle::FILL_TRANSPARENCY; $this->args["FILLFORECOLOR"] = DefaultStyle::FILL_FORE_COLOR; $this->args["FILLBACKCOLOR"] = DefaultStyle::FILL_BACK_COLOR; $this->args["FILLBACKTRANS"] = DefaultStyle::FILL_BACK_TRANS; $this->args["BORDERPATTERN"] = DefaultStyle::BORDER_PATTERN; $this->args["BORDERSIZEUNITS"] = DefaultStyle::BORDER_SIZE_UNITS; $this->args["BORDERCOLOR"] = DefaultStyle::BORDER_COLOR; $this->args["BORDERTHICKNESS"] = DefaultStyle::BORDER_THICKNESS; $this->args["LABELSIZEUNITS"] = DefaultStyle::LABEL_SIZE_UNITS; $this->args["LABELFONTSIZE"] = DefaultStyle::LABEL_FONT_SIZE; //Omission is considered false, which is the default. If you ever change //the default style values, uncomment the matching "true" values //$this->args["LABELBOLD"] = DefaultStyle::LABEL_BOLD; //$this->args["LABELITALIC"] = DefaultStyle::LABEL_ITALIC; //$this->args["LABELUNDERLINE"] = DefaultStyle::LABEL_UNDERLINE; $this->args["LABELFORECOLOR"] = DefaultStyle::LABEL_FORE_COLOR; $this->args["LABELBACKCOLOR"] = DefaultStyle::LABEL_BACK_COLOR; $this->args["LABELBACKSTYLE"] = DefaultStyle::LABEL_BACK_STYLE; $markupLayerDefinition = $this->CreateMarkupLayerDefinitionContent($markupFsId->ToString(), $className); $layerBs = new MgByteSource($markupLayerDefinition, strlen($markupLayerDefinition)); //Save to new resource or overwrite existing $resourceService->SetResource($markupLayerResId, $layerBs->GetReader(), null); //Add to markup registry $cmds = new MgFeatureCommandCollection(); $props = new MgPropertyCollection(); $props->Add(new MgStringProperty("ResourceId", $markupFsId->ToString())); $props->Add(new MgStringProperty("LayerDefinition", $markupLayerResId->ToString())); $props->Add(new MgStringProperty("Name", $markupLayerResId->GetName())); $props->Add(new MgStringProperty("FdoProvider", $fdoProvider)); $props->Add(new MgInt32Property("GeometryTypes", $geomTypes)); $insertCmd = new MgInsertFeatures("Default:MarkupRegistry", $props); $cmds->Add($insertCmd); $res = $featureService->UpdateFeatures($this->markupRegistryId, $cmds, false); MarkupManager::CleanupReaders($res); //Add to map $this->args["MARKUPLAYER"] = $markupLayerResId->ToString(); $this->OpenMarkup(); }
if (CheckForSaveData()) { // Validate inputs. if (empty($logRootFolder)) { throw new Exception($errInvalidLogRootFolder); } if ($maxLogSize <= 0) { throw new Exception($errInvalidMaxLogSize); } $selectedLogProps->ValidateProps(); // Create a ServerAdmin object for the Site Server. $serverAdmin = new MgServerAdmin(); $serverAdmin->Open($selectedServer, $userInfo); // Set general props $props = new MgPropertyCollection(); $prop = new MgStringProperty(MgConfigProperties::GeneralPropertyLogsPath, $logRootFolder); $props->Add($prop); $prop = new MgStringProperty(MgConfigProperties::GeneralPropertyMaxLogFileSize, round($maxLogSize * 1024.0)); $props->Add($prop); $prop = new MgStringProperty(MgConfigProperties::GeneralPropertyLogsDelimiter, $logDelimiters[$logDelimiter]); $props->Add($prop); $prop = new MgStringProperty("MaxLogFileSizeEnabled", $maxLogSizeEnabled ? "1" : "0"); $props->Add($prop); $serverAdmin->SetConfigurationProperties(MgConfigProperties::GeneralPropertiesSection, $props); // Set properties of selected log AddFrequency($selectedLogProps->filename, $archiveFrequency); $selectedLogProps->SetProps($serverAdmin); StripAndReturnFrequency($selectedLogProps->filename); $serverAdmin->Close(); $confirmationMsg = sprintf($confSuccessfulUpdate, $logLabels[$selectedLog]); } } catch (MgException $e) {
function InsertCommand($key) { $props = new MgPropertyCollection(); $keyProp = new MgStringProperty("SKEY", $key); $props->Add($keyProp); $nameProp = new MgStringProperty("NAME", "StringKey" . $key); $props->Add($nameProp); $wkt = new MgWktReaderWriter(); $agf = new MgAgfReaderWriter(); $geom = $wkt->Read("POLYGON ((20 20, 20 100, 120 100, 140 20, 20 20))"); $geomReader = $agf->Write($geom); $geomProp = new MgGeometryProperty("GEOM", $geomReader); $props->Add($geomProp); $cmd = new MgInsertFeatures("StringKey", $props); return $cmd; }
function UpdateMarkup() { $featureService = $this->site->CreateService(MgServiceType::FeatureService); $featureSourceId = $this->GetFeatureSource(); //HACK: Another leaky abstraction. SHP will always choose FeatId, so once again //use the class definition to determine the identity property name $clsDef = $this->GetClassDefinition(); $idProps = $clsDef->GetIdentityProperties(); $keyProp = $idProps->GetItem(0); $idName = $keyProp->GetName(); $propertyValues = new MgPropertyCollection(); $propertyValues->Add(new MgStringProperty('Text', trim($this->args['UPDATETEXT']))); $commands = new MgFeatureCommandCollection(); $commands->Add(new MgUpdateFeatures('Markup', $propertyValues, $this->BuildFeatureFilter($idName))); $result = $featureService->UpdateFeatures($featureSourceId, $commands, false); MarkupEditor::CleanupReaders($result); }
$map->GetLayers()->Insert(0, $addressLayer); } else { if ($addressLayer->GetVisible()) { // If the layer exists and is visible, then display the // previous results. EmitAddressResults($featureService, $addressMarkerDataResId, $mgSessionId); } } // Insert the results of the Geo-Code into the temporary // feature source and ensure the address marker layer // is visible. $geometryReaderWriter = new MgAgfReaderWriter(); $geometryFactory = new MgGeometryFactory(); $addrPoint = $geometryFactory->CreatePoint($geometryFactory->CreateCoordinateXY((double) $long, (double) $lat)); $properties = new MgPropertyCollection(); $properties->Add(new MgStringProperty('Address', $address1)); $properties->Add(new MgGeometryProperty('Location', $geometryReaderWriter->Write($addrPoint))); $commands = new MgFeatureCommandCollection(); $commands->Add(new MgInsertFeatures('AddressMarker', $properties)); $featureService->UpdateFeatures($addressMarkerDataResId, $commands, false); $addressLayer->SetVisible(true); $addressLayer->ForceRefresh(); $map->Save($resourceService); $success = true; } else { echo '<tr><td>Address not found: ' . $address . '<hr></td></tr>'; $success = false; } } catch (MgException $e) { echo $e->GetExceptionMessage(); echo '<br>';
} $geometryFactory = new MgGeometryFactory(); $mergedGeometries = $geometryFactory->CreateMultiGeometry($inputGeometries); // Add buffer features to the temporary feature source. // Create multiple concentric buffers to show area. // If the stylization for the layer draws the features // partially transparent, the concentric rings will be // progressively darker towards the center. // The stylization is set in the layer template file, which // is used in function CreateBufferLayer(). $commands = new MgFeatureCommandCollection(); for ($bufferRing = 0; $bufferRing < $bufferRingCount; $bufferRing++) { $bufferDist = $srs->ConvertMetersToCoordinateSystemUnits($bufferRingSize * ($bufferRing + 1)); $bufferGeometry = $mergedGeometries->Buffer($bufferDist, $srsMeasure); $properties = new MgPropertyCollection(); $properties->Add(new MgGeometryProperty('BufferGeometry', $agfReaderWriter->Write($bufferGeometry))); $commands->Add(new MgInsertFeatures('BufferClass', $properties)); } // Old way, pre MapGuide OS 2.0 //$featureService->UpdateFeatures($bufferFeatureResId, $commands, false); // New way, post MapGuide OS 2.0 $bufferLayer->UpdateFeatures($commands); $bufferLayer->SetVisible(true); $bufferLayer->ForceRefresh(); $bufferLayer->SetDisplayInLegend(true); $map->Save(); } } } else { echo 'No selected layers'; }
$val = $features->GetString($propName); break; case MgPropertyType::DateTime: $val = $features->GetDateTime($propName)->ToString(); break; } } // Generate XML to selection this feature // $sel = new MgSelection($map); $idProps = new MgPropertyCollection(); foreach ($idPropNames as $id) { $idPropType = $features->GetPropertyType($id); switch ($idPropType) { case MgPropertyType::Int32: $idProps->Add(new MgInt32Property($id, $features->GetInt32($id))); break; case MgPropertyType::String: $idProps->Add(new MgStringProperty($id, $features->GetString($id))); break; case MgPropertyType::Int64: $idProps->Add(new MgInt64Property($id, $features->GetInt64($id))); break; case MgPropertyType::Double: $idProps->Add(new MgDoubleProperty($id, $features->GetDouble($id))); break; case MgPropertyType::Single: $idProps->Add(new MgSingleProperty($id, $features->GetSingle($id))); break; case MgPropertyType::DateTime: $idProps->Add(new MgDateTimeProperty($id, $features->GetDateTime($id)));
private static function ParseFeatureNode($app, $propNodes, $agfRw, $wktRw, $classProps) { $props = new MgPropertyCollection(); for ($j = 0; $j < $propNodes->length; $j++) { $propNode = $propNodes->item($j); $name = $propNode->getElementsByTagName("Name")->item(0)->nodeValue; $valueNodes = $propNode->getElementsByTagName("Value"); $value = ""; $bNull = true; if ($valueNodes->length == 1) { $value = $valueNodes->item(0)->nodeValue; $bNull = false; } else { $bNull = true; } $pidx = $classProps->IndexOf($name); if ($pidx >= 0) { $propDef = $classProps->GetItem($pidx); if ($propDef->GetPropertyType() == MgFeaturePropertyType::GeometricProperty) { $geom = $wktRw->Read($value); $agf = $agfRw->Write($geom); $geomVal = new MgGeometryProperty($name, $agf); $props->Add($geomVal); } else { if ($propDef->GetPropertyType() == MgFeaturePropertyType::DataProperty) { $dataType = $propDef->GetDataType(); switch ($dataType) { case MgPropertyType::Boolean: if ($bNull) { $boolVal = new MgBooleanProperty($name, false); $boolVal->SetNull(true); } else { $boolVal = new MgBooleanProperty($name, self::StringToBool($value)); } $props->Add($boolVal); break; case MgPropertyType::Byte: if ($bNull) { $byteVal = new MgByteProperty($name, 0); $byteVal->SetNull(true); } else { $byteVal = new MgByteProperty($name, intval($value)); } $props->Add($byteVal); break; case MgPropertyType::DateTime: if ($bNull) { $dtVal = new MgDateTimeProperty($name, null); $dtVal > SetNull(true); } else { //We're expecting this: YYYY-MM-DD HH:mm:ss $dtMajorParts = explode(" ", $value); if (count($dtMajorParts) != 2) { throw new Exception($app->localizer->getText("E_INVALID_DATE_STRING", $value)); } $dateComponents = explode("-", $dtMajorParts[0]); $timeComponents = explode(":", $dtMajorParts[1]); if (count($dateComponents) != 3) { throw new Exception($app->localizer->getText("E_CANNOT_PARSE_DATE_STRING_INVALID_COMPONENT", $value, $dtMajorParts[0])); } if (count($timeComponents) != 3) { throw new Exception($app->localizer->getText("E_CANNOT_PARSE_DATE_STRING_INVALID_COMPONENT", $value, $dtMajorParts[1])); } $dt = new MgDateTime(); $y = intval(ltrim($dateComponents[0], "0")); $m = intval(ltrim($dateComponents[1], "0")); $d = intval(ltrim($dateComponents[2], "0")); $h = intval(ltrim($timeComponents[0], "0")); $min = intval(ltrim($timeComponents[1], "0")); $s = intval(ltrim($timeComponents[2], "0")); $dt->SetYear($y); $dt->SetMonth($m); $dt->SetDay($d); $dt->SetHour($h); $dt->SetMinute($min); $dt->SetSecond($s); $dtVal = new MgDateTimeProperty($name, $dt); } $props->Add($dtVal); break; case MgPropertyType::Decimal: case MgPropertyType::Double: if ($bNull) { $doubleVal = new MgDoubleProperty($name, 0.0); $doubleVal->SetNull(true); } else { $doubleVal = new MgDoubleProperty($name, floatval($value)); } $props->Add($doubleVal); break; case MgPropertyType::Int16: if ($bNull) { $i16val = new MgInt16Property($name, 0); $i16val->SetNull(true); } else { $i16val = new MgInt16Property($name, intval($value)); } $props->Add($i16val); break; case MgPropertyType::Int32: if ($bNull) { $i32val = new MgInt32Property($name, 0); $i32val->SetNull(true); } else { $i32val = new MgInt32Property($name, intval($value)); } $props->Add($i32val); break; case MgPropertyType::Int64: if ($bNull) { $i64val = new MgInt64Property($name, 0); $i64val->SetNull(true); } else { $i64val = new MgInt64Property($name, intval($value)); } $props->Add($i64val); break; case MgPropertyType::Single: if ($bNull) { $sinProp = new MgSingleProperty($name, 0.0); $sinProp->SetNull(true); } else { $sinProp = new MgSingleProperty($name, floatval($value)); } $props->Add($sinProp); break; case MgPropertyType::String: if ($bNull) { $strProp = new MgStringProperty($name, ""); $strProp->SetNull(true); } else { $strProp = new MgStringProperty($name, $value); } $props->Add($strProp); break; } } } } } return $props; }
function AddFeatureToCollection($propCollection, $agfRW, $featureId, $featureGeom) { $bufferProps = new MgPropertyCollection(); $idProp = new MgInt32Property("ID", $featureId); $bufferProps->Add($idProp); $geomReader = $agfRW->Write($featureGeom); $geomProp = new MgGeometryProperty("GEOM", $geomReader); $bufferProps->Add($geomProp); $propCollection->Add($bufferProps); }
if (!$arbitraryMapSrs) { $verMajor = subStr(GetSiteVersion(), 0, 1); if ($verMajor == '1') { $measure = new MgCoordinateSystemMeasure($srsMap); } else { $measure = $srsMap->GetMeasure(); } } else { $measure = null; } $geomFactory = new MgGeometryFactory(); $oGeom = $geomFactory->CreateMultiGeometry($inputGeometries); $oNewGeom = $oGeom->Buffer($dist, $measure); $geomProp = new MgGeometryProperty("GEOM", $agfRW->Write($oNewGeom)); $oPropertyColl = new MgPropertyCollection(); $oPropertyColl->Add($geomProp); $oCommandsColl->Add(new MgInsertFeatures($schemaName . ':' . $layerName, $oPropertyColl)); } } $result = $featureService->UpdateFeatures($featureSourceId, $oCommandsColl, false); $layer->ForceRefresh(); $map->Save($resourceService); echo "<Buffer>"; echo "<Layer>" . $layerId->ToString(); echo "</Layer>"; echo "</Buffer>"; } catch (MgException $e) { echo "last error"; echo "ERROR: " . $e->GetMessage() . "\n"; echo $e->GetDetails() . "\n"; echo $e->GetStackTrace() . "\n";
function SetProps($serverAdmin) { $props = new MgPropertyCollection(); if ($this->enabled) { $propVal = "1"; } else { $propVal = "0"; } $prop = new MgStringProperty($this->enabledPropStr, $propVal); $props->Add($prop); $prop = new MgStringProperty($this->filenamePropStr, $this->filename); $props->Add($prop); $separator = ""; $parmStr = ""; foreach ($this->parmsSelected as $parm) { $parmStr = $parmStr . $separator . $parm; $separator = ", "; } $prop = new MgStringProperty($this->parmsPropStr, $parmStr); $props->Add($prop); $serverAdmin->SetConfigurationProperties($this->propSectionStr, $props); }
ClearDataSource($featureSrvc, $dataSourceId, $featureName); } //Add the layer to the map, if it's not already in it if ($layer == null) { $legendName = GetLocalizedString("MEASURELAYER", $locale); $layer = new MgLayer($layerDefId, $resourceSrvc); $layer->SetDisplayInLegend(true); $layer->SetLegendLabel($legendName); $layers->Insert(0, $layer); } } // create a feature representing this segment and insert it into the data source // $measureProps = new MgPropertyCollection(); $partialProp = new MgDoubleProperty("PARTIAL", $distance); $measureProps->Add($partialProp); $totalProp = new MgDoubleProperty("TOTAL", $total); $measureProps->Add($totalProp); $agf = new MgAgfReaderWriter(); $geomReader = $agf->Write($geom); $geomProp = new MgGeometryProperty("GEOM", $geomReader); $measureProps->Add($geomProp); $cmd = new MgInsertFeatures($featureName, $measureProps); $commands = new MgFeatureCommandCollection(); $commands->Add($cmd); ReleaseReader($featureSrvc->UpdateFeatures($dataSourceId, $commands, false)); } if ($layer != null) { $layer->ForceRefresh(); } $map->Save($resourceSrvc);
function MakePoint($name, $x, $y) { $propertyCollection = new MgPropertyCollection(); $nameProperty = new MgStringProperty("NAME", $name); $propertyCollection->Add($nameProperty); $wktReaderWriter = new MgWktReaderWriter(); $agfReaderWriter = new MgAgfReaderWriter(); $geometry = $wktReaderWriter->Read("POINT XY ({$x} {$y})"); $geometryByteReader = $agfReaderWriter->Write($geometry); $geometryProperty = new MgGeometryProperty("GEOM", $geometryByteReader); $propertyCollection->Add($geometryProperty); return $propertyCollection; }