[mapguide-users] SetSelectionXML on layer from database
(PostgreSQL->PostgGIS)
Maciej Skorczewski
maciej.skorczewski at procad.pl
Mon Jun 11 05:14:56 EDT 2007
Hi
I try make SetSelectionXML method on my layer who come from PostGIS
(PostgreSQL database).
I make it whit SHP and all works fine...i get corect xml of selected
polygon...after call it MG make selection...
BUT.
When i try this whit layer who are in PostGIS i get bad xml (it is not
completed)
this xml come from SHP file:
<?xml version="1.0" encoding="UTF-8"?>
<FeatureSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="FeatureSet-1.0.0.xsd">
<Layer id="5b908772-0000-1000-8002-0019d10e3e0f">
<Class id="SHP_Schema:RoadCenterLines">
<ID>DgEAAA==</ID></Class></Layer></FeatureSet>
this xml come from PostGIS.
<?xml version="1.0" encoding="UTF-8"?>
<FeatureSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="FeatureSet-1.0.0.xsd">
</FeatureSet>
what is wrong whit that?
take a look on my code.
------- php code begin----------------
MgInitializeWebTier ($configFilePath);
$userInfo = new MgUserInformation($mgSessionId);
$siteConnection = new MgSiteConnection();
$siteConnection->Open($userInfo);
$resourceService=$siteConnection->CreateService(MgServiceType::ResourceService);
$featureService=$siteConnection->CreateService(MgServiceType::FeatureService);
$map = new MgMap();
$map->Open($resourceService, 'budynek2_db');
$pomQuery = new MgFeatureQueryOptions();
$pomQuery->SetFilter("Ogc_fid = '".trim($key)."'");
//i get db connection to postgis
//normaly it should be shp source
$pomResId = new
MgResourceIdentifier("Library://budynek2/db_postgres/db.FeatureSource");
//this is my layer
$featureReader = $featureService->SelectFeatures($pomResId,
"SDF_2_Schema:0x_poziom_0", $pomQuery);
$layer = $map->GetLayers()->GetItem('0x_poziom_0');
$selection = new MgSelection($map);
$selection->AddFeatures($layer, $featureReader, 0);
$selectionXml = $selection->ToXml();
echo "<script type='text/javascript'>\n function OnPageLoad() {\n";
echo "selectionXml = '$selectionXml';\n
parent.SetSelectionXML(selectionXml);\n";
echo "$selectionXml";
echo "}\n</script>";
------- php code end----------------
Maciej Skórczewski
More information about the mapguide-users
mailing list