2009-12-05, 19:37
by nursix

Comments Off

In re: Interoperability

David W. Bitner promptly added XSLT templates for KML and GeoRSS:

“This will be sooooo awesome for being able to quickly extend to read/write any format”

“Nice thing about this architecture is it allows someone like me to come in and add new formats without having to understand *any* of the code going on”

:)

2009-12-04, 02:31
by nursix

Comments Off

Interoperability

I actually like that built-in GPS of my NOKIA 6220 classic cellphone. This is not a highly advanced professional equipment though, and I’m just using it to map the landmarks of my daily travel – for no serious reason, but just for fun.

However, here is what makes it a Sahana equipment:

The landmarks collection saved in the cellphone can be exported in a very comprehensible XML format, and shared via SMS, E-Mail or Bluetooth.

The XML interface of the SahanaPy RESTful API uses in-line XSLT transformation for export and import of data, so I thought it would perhaps be cool to have a template to import the landmark positions from my cellphone as GIS locations in SahanaPy.

So I added the following XSLT template as “lmx.xsl” to sahana/static/xslt/import:


<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:lm="http://www.nokia.com/schemas/location/landmarks/1/0">

<xsl:output method="xml"/>

<xsl:template match="/">
<sahanapy>
<xsl:apply-templates select=".//lm:landmark"/>
</sahanapy>
</xsl:template>

<xsl:template match="lm:landmark">
<resource name="gis_location">
<data field="gis_feature_type" value="1">Point</data>
<xsl:apply-templates select="./lm:name"/>
<xsl:apply-templates select="./lm:coordinates"/>
</resource>
</xsl:template>

<xsl:template match="lm:name">
<data field="name">
<xsl:value-of select="./text()"/>
</data>
</xsl:template>

<xsl:template match="lm:coordinates">
<data field="lat">
<xsl:value-of select="./lm:latitude/text()"/>
</data>
<data field="lon">
<xsl:value-of select="./lm:longitude/text()"/>
</data>
</xsl:template>
</xsl:stylesheet>

Then, I added “lmx” to the supported XML import formats of 01_RESTlike_controller.py:

shn_xml_import_formats = ["xml", "lmx"] #: Supported XML import formats

After that, I sent the landmarks file from my phone (via bluetooth) to my server and import it just by calling the following URL:

http://localhost:8000/sahana/gis/location/create.lmx?filename=/home/dominic/landmarks.lmx

Done! Now I can use my “landmarks” to track people and shelters and other things, view them on maps, link other resources…

Finally, I added another template to be able to export SahanaPy GIS locations as NOKIA landmarks in order to import them on my cellphone, and that works equally good, just exporting by calling:

http://localhost:8000/sahana/gis/location.lmx

and sending the exported file via bluetooth to the phone – it immediately audibly indicates a new message – and when you choose “View” for that message then you get a list of locations which you can easily view on map or load into the navigation system.

Cool.

This is the first implemented cross-platform interoperability feature in SahanaPy, based merely on the SahanaPy RESTful API!

 
  
 
  • Categories


    • follow me on Twitter

    • Event Calendar

      September 2010
      M T W T F S S
       12345
      6789101112
      13141516171819
      20212223242526
      27282930EC

    • Archives


    • Meta