But today we had user reporting to us that some layers don't appear on the map although they used to appear in the past.
As it turned out spatial filters had been assigned to those layers but the filters covered our area of interest and therefore no one noticed it. But a few weeks ago we switched to a new coordinate system and had to transform our spatial data into the new system. The spatial filters defined in some layers had not been transformed as we had not been aware of them and assuming all had been removed. After removing the spatial filters the layers re-appeared on our maps.
The issue with regards to layers getting a spatial filter assigned when being published has been reported to Autodesk some time back. Maybe it has been fixed by now in newer releases.
Here is the core bit of the PHP based script for removing spatial filters - as usual a quick and dirty solution:
if ($_POST['hiddenparam'] == '') die();
if ($_POST['projektpfad'] == '') die();
$MGAdminPassword = $_POST['password'];
try
{
include './config.schema.list.php';
include '../vaw.lib/initializeMapGuide.php';
$Verzeichnis = $_POST['projektpfad'];
echo "<html><body>";
echo "<p>MapGuide Pfad: $Verzeichnis </p>";
$VerzeichnisResourceId = new MgResourceIdentifier($Verzeichnis);
$LayerReader = $resourceService->EnumerateResources($VerzeichnisResourceId, -1, "");
$Xml = $LayerReader->ToString();
$LDomDoc = DOMDocument::loadXML($Xml);
$pfad = new DOMXPath($LDomDoc);
$frage = "//ResourceDocument/ResourceId";
$ebenen = $pfad->query($frage);
$anzlayer = 0;
foreach($ebenen as $knoten)
{
$Layer = $knoten->nodeValue;
$LayerResourceId = new MgResourceIdentifier($Layer);
$layerName = $LayerResourceId->GetName();
$layerType = $LayerResourceId->GetResourceType();
if($layerType == 'LayerDefinition')
{
echo "<b>Layername: $layerName </b><br>";
$tmpReader = $resourceService->GetResourceContent($LayerResourceId);
$layerXML = $tmpReader->ToString();
$doc = DOMDocument::loadXML($layerXML);
$FilterNode = $doc->getElementsByTagName('Filter');
foreach($FilterNode as $node)
{
if(!stristr($node->nodeValue, "GeomFromText"))
{
//kein Spatial Filter
//echo " <b>Kein Spatial Filter.</b><br>";
}
else
{
$node->nodeValue = '';
echo "<b>Spatial Filter - vorhanden und entfernt.</b> <br><br>";
echo "<small>vorhandene Filter: {$node->nodeValue} .</small>";
}
}
//echo $doc->ToString();
$modifiedLayerDefinition = $doc->saveXML();
$byteSource = new MgByteSource($modifiedLayerDefinition, strlen($modifiedLayerDefinition));
$byteSource->SetMimeType(MgMimeType::Xml);
//$resourceId = new MgResourceIdentifier($LayerResourceId);
$resourceService->SetResource($LayerResourceId, $byteSource->GetReader(), null);
}
}
}
catch ( MgException $e )
{
$errorMsg = $errAuthenticationFailed;
}
catch ( Exception $e )
{
$errorMsg = $e->getMessage();
}
Map 2013, SP2
No comments:
Post a Comment