You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by pub cog <pu...@gmail.com> on 2009/05/27 17:33:51 UTC

Geographical Datastore and Posgis integration

Hi,

I'm building a datastore to hold geographical informations (kml files)
providing REST webservices to store, retrieve and search those
informations.

As a first iteration, I build my own datastore from scratch using
postgres/postgis (1), the restlet framework (2) and some old school
jdbc.

For the second iteration, new features appeared: versionning, unique
id generation on creation, update a ressource etc...

Many of those features are already addressed by Sling/JCR:
1- 'versionning' JCR is suppose to provide sch a thing, but I didn't
find how to use it in Sling; any link is welcome ;)
2- 'uid' using wildcards (path/*) as explain in the tutorial (3)
3- 'update' builtin Sling


My main concern is about Posgis :(


In my current datastore, I have geographical search functionnality,
meaning I have a webservice like this:
http://www.domain.com/rest/search?south=43.52&north=43.67&west=1.36&east=1.55
returning a list of resources urls like this:
  http://www.domain.com/.../1.kml
  http://www.domain.com/.../2.kml
  http://www.domain.com/.../3.kml

The actual search is based on postgis sql builtin function.

Currently the process has 2 main steps:
  Step n°1- on ressource creation/update, I parse the provided kml
file to extract geographical informations > create a 'geom' (4) using
postgis function and store it in a database table column
  Step n°2- on search I transform query coordinnates into a 'geom' and
use it against the computed geom(s) created above > I found rows in
the db and return them as a list


How could I do this with Sling ?


I have some ideas, could you tell me if it's possible or even the
right direction ?

On an architectural point of view, I thought about having a Sling
server and a postgis database separate.
  - Sling:  will actually store files and properties associated with them
  - Postgis: will store only a jcr path and 'geom' informations
  - Java: code some java component(s) (osgi bundle ?) to synchronize both

Step n°1: I was thinking to use some kind of 'hook' on ressource
creation/update to compute the geom and store a couple
(path_in_jcr/geom) in postgres/postgis
Should I do such a hook by "Extending the SlingPostServlet" describe
in "Advanced Topic" (5) ?!

Step n°2: tricky :(
I've read about resources search in "Querying Resources" (6), but it's
still blury :(


Additionnal information:
- I don't care about portability accross different jcr backend, at
least not at the moment ;)


Thanks
__
Benjamin Francisoud
http://francisoud.blogspot.com


[1] http://postgis.refractions.net/
[2] http://www.restlet.org/
[3] http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html#Additional
examples: "Let Sling generate the path of a newly created node."
[4]geom: http://postgis.refractions.net/documentation/manual-1.3/ch04.html#RefObject
[5] http://incubator.apache.org/sling/site/manipulating-content-the-slingpostservlet.html
[6] http://incubator.apache.org/sling/site/resources.html

Re: Geographical Datastore and Posgis integration

Posted by pub cog <pu...@gmail.com>.
On Wed, May 27, 2009 at 7:45 PM, Vidar Ramdal <vi...@idium.no> wrote:
>
> Just a quick thought. I don't know much about KML, but from the docs
> it looks like a fairly simple XML format.

exactly it's just xml.

> Have you considered storing the KML data as JCR nodes, and not as KML files?
> That would certainly make it easier to implement advanced search
> features, as you describe.
>

You mean instead of creating a node /path/my_file.kml and store the
content there.
creates nodes like they are in the kml, for example, if kml looks like:

<kml>
<Folder>
<Folder>
<Placemark>...</Placemark>
</Folder>
</Folder>
</kml>

store them as jcr node like this ?
kml
|__ Folder
    |__Folder
        |__ Placemark
...


If that's what you meant, I didn't thought of this, why not... I need
to think about it...
search may be easier but that means I need to make some kind of
automatic parsing transformation to jcr ,nodes ?

Re: Geographical Datastore and Posgis integration

Posted by Vidar Ramdal <vi...@idium.no>.
2009/5/27 pub cog <pu...@gmail.com>:

> The actual search is based on postgis sql builtin function.
>
> Currently the process has 2 main steps:
>  Step n°1- on ressource creation/update, I parse the provided kml
> file to extract geographical informations > create a 'geom' (4) using
> postgis function and store it in a database table column
>  Step n°2- on search I transform query coordinnates into a 'geom' and
> use it against the computed geom(s) created above > I found rows in
> the db and return them as a list
>
>
> How could I do this with Sling ?

Just a quick thought. I don't know much about KML, but from the docs
it looks like a fairly simple XML format.
Have you considered storing the KML data as JCR nodes, and not as KML files?
That would certainly make it easier to implement advanced search
features, as you describe.

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway
+47 21 531941, ext 2070