GML to Ptolemy3D_POI
- Note: there appears to be a related document here
A request of the form : http://220.218.254.236/cgi-bin/mapserv?/&SERVICE=WFS&VERSION=1.0.0&REQUEST=getFeature&map=seattle_wfs.map&typename=poi
will simply return all the pois that the WFS is set up to return.
A request of the form : http://220.218.254.236/cgi-bin/mapserv?/&SERVICE=WFS&VERSION=1.0.0&REQUEST=getFeature&map=seattle_wfs.map&typename=poi&maxFeatures=20
will return a maximum of 20 pois that the WFS is set up to return.
Example of GML returned from WFS :
<wfs:FeatureCollection
xmlns="http://www.ttt.org/myns" xmlns:myns="http://www.ttt.org/myns" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://ogc.dmsolutions.ca/wfs/1.0.0/WFS-basic.xsd
http://www.ttt.org/myns http://220.218.254.236/cgi-bin/mapserv?map=seattle_wfs.map&service=WFS&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=poi">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326"> <gml:coordinates>-122.527880,47.184897 -121.955223,47.927340</gml:coordinates> </gml:Box>
</gml:boundedBy>
<gml:featureMember>
<poi>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326"> <gml:coordinates>-122.334200,47.584420 -122.334200,47.584420</gml:coordinates> </gml:Box>
</gml:boundedBy> <gml:pointProperty>
<gml:Point srsName="EPSG:4326"> <gml:coordinates>-122.334200,47.584420</gml:coordinates> </gml:Point>
</gml:pointProperty> <oid>675717</oid> <id>1608</id> <name>Grand Central on the Park Bldg</name> <group_id>2</group_id> <user_id>1</user_id>
</poi>
</gml:featureMember>
... </wfs:FeatureCollection>
The above GML is then transformed by an XSLT such as the following:
<?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gml="http://www.opengis.net/gml"> <xsl:output indent="yes" method="xml"/> <xsl:strip-space elements="*" />
<xsl:template match="text()"/>
<xsl:template match="/"> <pois> <!--kanji: false= use texture font, true = use Graphics object--> <xsl:attribute name="kanji">false</xsl:attribute> <xsl:attribute name="iconprefix">/Ptolemy3DLib/icons/SeattleSymbol/icon_1_</xsl:attribute> <!--Colours: Red:Green:Blue:Alpha If Alpha = 0, Colour is invisible--> <xsl:attribute name="bgcolor">100:100:250:150</xsl:attribute> <xsl:attribute name="fcolor">255:255:255:255</xsl:attribute> <xsl:attribute name="bordercolor">0:0:255:255</xsl:attribute> <xsl:attribute name="fontwidth">1.3</xsl:attribute> <xsl:attribute name="fontheight">1.8</xsl:attribute> <xsl:attribute name="position">RM</xsl:attribute> <xsl:attribute name="maxalt">50000</xsl:attribute> <xsl:attribute name="minalt">0</xsl:attribute> <xsl:attribute name="fontFile">/fonts/verdana36both.fnt</xsl:attribute> <xsl:attribute name="pinpoint">true</xsl:attribute> <xsl:attribute name="numicons">32</xsl:attribute> <xsl:apply-templates select="*"/> </pois> </xsl:template>
<xsl:template match="//featureMember/poi"> <poi> <xsl:attribute name="id"><xsl:value-of select="group_id/text()"/></xsl:attribute> <xsl:attribute name="label"><xsl:value-of select="name/text()"/></xsl:attribute> <xsl:attribute name="obj_id"><xsl:value-of select="id/text()"/></xsl:attribute> <xsl:call-template name="coordinates"> <xsl:with-param name="coords" select="./pointProperty/Point/coordinates/text()"/> </xsl:call-template> </poi> </xsl:template>
<xsl:template name="coordinates"> <xsl:param name="coords" select="coords" /> <xsl:attribute name="lon"><xsl:value-of select="substring-before($coords,',')"/></xsl:attribute> <xsl:attribute name="lat"><xsl:value-of select="substring-after($coords,',')"/></xsl:attribute> </xsl:template>
</xsl:stylesheet>
which generates XML in the form that Ptolemy3D? expects:
<?xml version="1.0" encoding="UTF-8"?> <pois xmlns:gml="http://www.opengis.net/gml" kanji="false" iconprefix="/Ptolemy3DLib/icons/SeattleSymbol/icon_1_" bgcolor="100:100:250:150" fcolor="255:255:255:255" bordercolor="0:0:255:255" fontwidth="1.3" fontheight="1.8" position="RM" maxalt="50000" minalt="0" fontFile="/fonts/verdana36both.fnt" pinpoint="true" numicons="32"> <poi id="6" label="Internal Revenue Service" obj_id="1659" lon="-122.334890" lat="47.604770"/> <poi id="2" label="Financial Center" obj_id="1592" lon="-122.334320" lat="47.607630"/> <poi id="16" label="Madison Renaissance Hotel" obj_id="1857" lon="-122.330690" lat="47.607020"/> <poi id="16" label="Pacific Plaza" obj_id="1756" lon="-122.333560" lat="47.606800"/> <poi id="6" label="Federal Courthouse" obj_id="858" lon="-122.331880" lat="47.606640"/> <poi id="2" label="College Club Bldg" obj_id="1542" lon="-122.331730" lat="47.606580"/> <poi id="2" label="1001 4th Ave Plaza Bldg" obj_id="1444" lon="-122.333360" lat="47.605870"/> <poi id="3" label="Seattle City Light" obj_id="1824" lon="-122.330140" lat="47.604760"/> <poi id="2" label="First Interstate Center" obj_id="1600" lon="-122.334000" lat="47.605610"/> <poi id="2" label="Bank of California Center" obj_id="1495" lon="-122.332270" lat="47.605390"/> <poi id="16" label="Pacific Hotel" obj_id="1751" lon="-122.332260" lat="47.605370"/> <poi id="2" label="Bank of America Tower" obj_id="1549" lon="-122.330450" lat="47.605070"/> <poi id="6" label="Passport Office" obj_id="1759" lon="-122.334580" lat="47.604560"/> <poi id="6" label="Coast Guard 13th District" obj_id="1537" lon="-122.334580" lat="47.604560"/> <poi id="6" label="Federal Bldg" obj_id="1586" lon="-122.334580" lat="47.604560"/> <poi id="2" label="905 2nd Ave Bldg" obj_id="1463" lon="-122.334480" lat="47.604450"/> <poi id="4" label="Metro Transit Accessible Services" obj_id="1709" lon="-122.334430" lat="47.604400"/> <poi id="2" label="Exchange Bldg" obj_id="1583" lon="-122.334430" lat="47.604400"/> <poi id="2" label="Central Bldg" obj_id="1530" lon="-122.332790" lat="47.604280"/> <poi id="2" label="Marion Bldg" obj_id="1696" lon="-122.333950" lat="47.603880"/> </pois>
Ptolemy3D? parses the above XML and displays the POIs in the viewer.
