[Geoserver-devel] SVG Mobile Output Format with GeoServer (for iPhone client)?

Hello list!

I wrote this to this list [Geoserver-users] but now I saw, that there is a [Geoserver-devel] list so I am sending this there too.
Sorry for the x-post. Maybe it can be deleted in the users list?

Some time ago I asked here about SVG support in OpenLayers and in GeoWebCache because I am going to implement a map client on the iPhone to do some investigation on automated-zooming navagation.

Due to limited capabilities (CPU, RAM) of an iPhone and the bandwidth I need the SVG to be as small as possible so I was looking for a map server that could output small and still rich and nice SVG. Well, I did not find any server which does this. There is SUASServer but the output SVG-T output I got was kind of strange because it was SVG with a lot of tiles containing PNG files. If you know some server with nice SVG, please let me know.

So I decided it would be nice to add SVG Mobile (Basic and/or Tiny profile) output format to GeoServer and before I start I want to know what you think and let you know my doubts:

  1. Shoud it be WMS or WFS service?
  2. On geoserver.org there are two tutorials on how to add custom output format

Create your own Output Format
Creating a WFS Output Format

In what way are they different? If I decide for WFS which approach should I use?

  1. my biggest concern using geoserver is that I am afraid I can’t make use of the PostGIS function AsSVG() where I could optimize output by setting relative coords and limit precision.

  2. For my purpose I guess I would use SVG Basic instead of Tiny because Tiny profile does not support textpath element which is nice for street names.

  3. A gzip output would also be nice to reduce the file size

  4. Since I need a lot of map data to test navigation I would like to import OSM data (OpenStreetMap) into the PostGIS database. I know the tables of OSM are a mess, but I just need the name from the FeatureInfo (eg. city and streetnames) GeoFabrik offers shapefiles which can be imported into PostGIS easily via shp2psql

  5. If everything works fine i might take a look at SVG tiling support in GeoWebCache as Andrea stated that it should be generally possible, altough as soon as SVG Basic Output is ready I have to implement that iPhone client.

  6. Does anyone know by chance what is faster to render for the webkit SVG renderer: absolute or relative path coords?

I would love to do my developing as nice as possible so it might be possibly reused in Geoserver in the future if there is interest in it.

You might have noticed, that I am not an experienced GIS developer. I have no problem programming Java but I am new to all this GIS stuff.

Thanks a lot for any comments

Ivo


Deutsche Telekom Laboratories (Berlin)

(doing my diploma project there)

Ivo Brodien ha scritto:

Hello list!

I wrote this to this list [Geoserver-users] but now I saw, that there is a [Geoserver-devel] list so I am sending this there too.
Sorry for the x-post. Maybe it can be deleted in the users list?

Some time ago I asked here about SVG support in OpenLayers and in GeoWebCache because I am going to implement a map client on the iPhone to do some investigation on automated-zooming navagation.

Due to limited capabilities (CPU, RAM) of an iPhone and the bandwidth I need the SVG to be as small as possible so I was looking for a map server that could output small and still rich and nice SVG. Well, I did not find any server which does this. There is SUASServer <http://www.easywms.com/&gt; but the output SVG-T output I got was kind of strange because it was SVG with a lot of tiles containing PNG files. If you know some server with nice SVG, please let me know.

So I decided it would be nice to add SVG Mobile (Basic and/or Tiny profile) output format to GeoServer and before I start I want to know what you think and let you know my doubts:

1) Shoud it be WMS or WFS service?

It depends, with vector output there's always a grey area. As a rule
of thum, if the output has any styling (it has to contain color, line
width, filled polygons and the like, and be driven by an SLD) then
it should be a WMS output format, since there is no concept of
styling in WFS.

2) On geoserver.org there are two tutorials on how to add custom output format

Create your own Output Format <http://geoserver.org/display/GEOSDOC/Create+your+own+Output+Format&gt;
Creating a WFS Output Format <http://geoserver.org/display/GEOSDOC/Creating+a+WFS+Output+Format&gt;

In what way are they different? If I decide for WFS which approach should I use?

GeoServer already has two SVG based output formats, one that
is based on Batik and that supports SLD almost fully but it's kind
of slow, and another one that supports very limited styling but
is faster.
I don't know anything about these SVG profiles for mobile hardware,
but I guess you'll need total control over the output, so I suggest
you look into the one that does not do full styling, and adapt
it to your needs. The classes can be found in the WMS module,
org.vfny.geoserver.wms.responses.map.svg package, and in particular
the low styling high performance classes are SVGMapProducer and
EncodeSVG, whilst the full styling lower performance is
SVGBatikMapProducer.

3) my biggest concern using geoserver is that I am afraid I can't make use of the PostGIS function AsSVG() <http://svg.cc/pg/assvg/&gt; where I could optimize output by setting relative coords and limit precision.

True, a WMS output format receives a MapContext definitions, that
do in turn have FeatureSource object. A good output format must not
make assumptions on the backend, and the PostGIS data store won't allow
you to make use of that function either.
Then again, you can use the GeoTools Decimator class to perform
a simple on the fly generalization (that class assumes you're using
a special coordinate sequence class for your geometries, we can
talk details about this in a separate mail).

4) For my purpose I guess I would use SVG Basic instead of Tiny because Tiny profile does not support textpath element which is nice for street names.

5) A gzip output would also be nice to reduce the file size

This is handled automatically by GeoServer already. There is a
filter installed in GeoServer that compresses text based outputs
on the fly. You just have to add the svg mime type (image/svg+xml)
to the list of compressed types, look into web.xml.

6) Since I need a lot of map data to test navigation I would like to import OSM data (OpenStreetMap) into the PostGIS database. I know the tables of OSM are a mess, but I just need the name from the FeatureInfo (eg. city and streetnames) GeoFabrik <http://download.geofabrik.de/&gt; offers shapefiles which can be imported into PostGIS easily via shp2psql

Yeah, you can also download OSM data from cloudmade.com

7) If everything works fine i might take a look at SVG tiling support in GeoWebCache as Andrea stated that it should be generally possible, altough as soon as SVG Basic Output is ready I have to implement that iPhone client.

8) Does anyone know by chance what is faster to render for the webkit SVG renderer: absolute or relative path coords?

No idea.

I would love to do my developing as nice as possible so it might be possibly reused in Geoserver in the future if there is interest in it.

That would be great indeed :slight_smile:

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Ivo Brodien wrote:

7) If everything works fine i might take a look at SVG tiling support in GeoWebCache as Andrea stated that it should be generally possible, altough as soon as SVG Basic Output is ready I have to implement that iPhone client.

Adding basic SVG support to GeoWebCache is very easy. The only thing that doesn't work for non-raster formats is metatiling (request 3x3 tiles at a time, then chop the image up, to avoid duplicate labels etc).

I don't know whether Batik or some other library can easily be used to divide SVG documents into subtiles ? But this may not be a problem at all.

-Arne

--
Arne Kepp
OpenGeo - http://opengeo.org
Expert service straight from the developers

Hi Ivo,

On Monday 17 November 2008 07:17:53 am Ivo Brodien wrote:

Hello list!

I wrote this to this list [Geoserver-users] but now I saw, that there
is a [Geoserver-devel] list so I am sending this there too.
Sorry for the x-post. Maybe it can be deleted in the users list?

Some time ago I asked here about SVG support in OpenLayers and in
GeoWebCache because I am going to implement a map client on the iPhone
to do some investigation on automated-zooming navagation.

Due to limited capabilities (CPU, RAM) of an iPhone and the bandwidth
I need the SVG to be as small as possible so I was looking for a map
server that could output small and still rich and nice SVG.

Great. Currently the two svg producers in geoserver give you one of those
features each :slight_smile:
I would say you need to go for WMS, and invest some effort in giving the
streamed output format a nicer styling. It should already provide you with
relative coords, control over the number of decimals to use, gzipped output,
and produce a pretty clean output without too many grief but a couple <g>
elements.

Well, I
did not find any server which does this. There is SUASServer but the
output SVG-T output I got was kind of strange because it was SVG with
a lot of tiles containing PNG files. If you know some server with nice
SVG, please let me know.

So I decided it would be nice to add SVG Mobile (Basic and/or Tiny
profile) output format to GeoServer and before I start I want to know
what you think and let you know my doubts:

1) Shoud it be WMS or WFS service?
2) On geoserver.org there are two tutorials on how to add custom
output format

Create your own Output Format
Creating a WFS Output Format

In what way are they different? If I decide for WFS which approach
should I use?

3) my biggest concern using geoserver is that I am afraid I can't make
use of the PostGIS function AsSVG() where I could optimize output by
setting relative coords and limit precision.

4) For my purpose I guess I would use SVG Basic instead of Tiny
because Tiny profile does not support textpath element which is nice
for street names.

5) A gzip output would also be nice to reduce the file size

6) Since I need a lot of map data to test navigation I would like to
import OSM data (OpenStreetMap) into the PostGIS database. I know the
tables of OSM are a mess, but I just need the name from the
FeatureInfo (eg. city and streetnames) GeoFabrik offers shapefiles
which can be imported into PostGIS easily via shp2psql

7) If everything works fine i might take a look at SVG tiling support
in GeoWebCache as Andrea stated that it should be generally possible,
altough as soon as SVG Basic Output is ready I have to implement that
iPhone client.

hummm... I wonder if tiling would be possible with svg at all... I mean, one
can of course clip the geometries to the tile bounds, but my concern is with
styling... putting together two tiles with a shared geometry would give you a
line at the tile margin instead of a seamless union of the two geometry
parts?

8) Does anyone know by chance what is faster to render for the webkit
SVG renderer: absolute or relative path coords?

Who knows... relative coords are meant to give you a fairly compressed output
afaik.. rendering wise it'd be up to the implementation so no idea really...

I would love to do my developing as nice as possible so it might be
possibly reused in Geoserver in the future if there is interest in it.

cool. Afaik giving some styling to the current streamed svg output would be
what you need.

You might have noticed, that I am not an experienced GIS developer. I
have no problem programming Java but I am new to all this GIS stuff.

that's all you need and communication with the list to help you out :slight_smile:

best regards,

Gabriel

Thanks a lot for any comments

Ivo

---
Deutsche Telekom Laboratories (Berlin)
(doing my diploma project there)

Hello everybody,

I am sorry for answering so late. Thanks for the motivating answers.

1) Shoud it be WMS or WFS service?

Andrea Aime wrote:
It depends, with vector output there's always a grey area. As a rule
of thum, if the output has any styling (it has to contain color, line
width, filled polygons and the like, and be driven by an SLD) then
it should be a WMS output format, since there is no concept of
styling in WFS.

Ok, I will do it as a WMS service then, since I the plan ist to deliver styled maps.

GeoServer already has two SVG based output formats, one that
is based on Batik and that supports SLD almost fully but it's kind
of slow, and another one that supports very limited styling but
is faster.
I don't know anything about these SVG profiles for mobile hardware,
but I guess you'll need total control over the output, so I suggest
you look into the one that does not do full styling, and adapt
it to your needs. The classes can be found in the WMS module,
org.vfny.geoserver.wms.responses.map.svg package, and in particular
the low styling high performance classes are SVGMapProducer and
EncodeSVG, whilst the full styling lower performance is
SVGBatikMapProducer.

I started wit the cloning and adapting the SVGMapProdcer.java, EncodeSVG.java and added my Render so it can be choosen via the WebInterface as the SVG-Renderer.

3) my biggest concern using geoserver is that I am afraid I can't make use of the PostGIS function AsSVG() <http://svg.cc/pg/assvg/&gt; where I could optimize output by setting relative coords and limit precision.

True, a WMS output format receives a MapContext definitions, that
do in turn have FeatureSource object. A good output format must not
make assumptions on the backend, and the PostGIS data store won't allow
you to make use of that function either.
Then again, you can use the GeoTools Decimator class to perform
a simple on the fly generalization (that class assumes you're using
a special coordinate sequence class for your geometries, we can
talk details about this in a separate mail).

Okay so I guess I will just have to use external tools to make some nicer SVG Data instead of letting PostGIS make all the work, which I thought would be faster than doing it in Java. PostGIS also has the Simplify function which does the generalization. It would be nice, if we could talk about the Decimators generalization in separate mail as you suggested Andrea. It sounds as if I also could use this class to convert the geo data to my local screen device coordinate system, so the client does not neet to do calculations?

4) For my purpose I guess I would use SVG Basic instead of Tiny because Tiny profile does not support textpath element which is nice for street names.
5) A gzip output would also be nice to reduce the file size

This is handled automatically by GeoServer already. There is a
filter installed in GeoServer that compresses text based outputs
on the fly. You just have to add the svg mime type (image/svg+xml)
to the list of compressed types, look into web.xml.

Great, works fine.

6) Since I need a lot of map data to test navigation I would like to import OSM data (OpenStreetMap) into the PostGIS database. I know the tables of OSM are a mess

I have to correct myself. The data povided by GeoFabrik is pretty nice. When I used a tool osm2psql it imported the whole table structure. THe GeoFabrik data is very simple.

Cheers
Ivo

Adding basic SVG support to GeoWebCache is very easy. The only thing that doesn't work for non-raster formats is metatiling (request 3x3 tiles at a time, then chop the image up, to avoid duplicate labels etc).

I don't know whether Batik or some other library can easily be used to divide SVG documents into subtiles ? But this may not be a problem at all

I would like to know how to add that if it is really that easy. I guess just insalling the GWC and pointing my client will not do the job automatically? A simple Cache is fine, at least for my purposes. At the moment I could live without meta-tiling.

Bye
Ivo

Sorry for sounding in late, but a few more thoughts.

OpenGeo is doing some RnD on iphone stuff for OpenLayers, trying to build a community of everyone trying to get OL on the iPhone. See the posts on http://docs.opengeo.org/geospiel/ And email list at http://www.openplans.org/projects/iol/lists/iol-discussion

One more point on not using PostGIS asSVG() is that it won't pick up the styling that you've defined for your layer in GeoServer. Of course only the batik svg one does that now.

The ideal svg output format would likely end up being similar to the KML one. Both are XML outputs that should use styling. Ideally we'd have a nice refactoring that lets them share good code, and also share code with the non-XML formats, as there is now some code replication.

For 'tiling', the ideal solution would be to do something like we've done in KML, with GWC, for 'super overlays'. See http://geoserver.org/display/GEOS/Vector+Super+Overlays GeoServer figures out which data to return first, and GWC caches it all at the right level. I could see it being adapted to SVG in a nice way, to stream in data as users zoom in. Of course it's a non-trivial amount of work, but it would be quite cool. I think there's a lot of potential directions it could go, like incorporating generalization and the like.

But yeah, an improved SVG output format for GeoServer would be a great improvement, even without all the super advanced stuff.

best regards,

Chris

Ivo Brodien wrote:

Hello everybody,

I am sorry for answering so late. Thanks for the motivating answers.

1) Shoud it be WMS or WFS service?

Andrea Aime wrote:
It depends, with vector output there's always a grey area. As a rule
of thum, if the output has any styling (it has to contain color, line
width, filled polygons and the like, and be driven by an SLD) then
it should be a WMS output format, since there is no concept of
styling in WFS.

Ok, I will do it as a WMS service then, since I the plan ist to deliver styled maps.

GeoServer already has two SVG based output formats, one that
is based on Batik and that supports SLD almost fully but it's kind
of slow, and another one that supports very limited styling but
is faster.
I don't know anything about these SVG profiles for mobile hardware,
but I guess you'll need total control over the output, so I suggest
you look into the one that does not do full styling, and adapt
it to your needs. The classes can be found in the WMS module,
org.vfny.geoserver.wms.responses.map.svg package, and in particular
the low styling high performance classes are SVGMapProducer and
EncodeSVG, whilst the full styling lower performance is
SVGBatikMapProducer.

I started wit the cloning and adapting the SVGMapProdcer.java, EncodeSVG.java and added my Render so it can be choosen via the WebInterface as the SVG-Renderer.

3) my biggest concern using geoserver is that I am afraid I can't make use of the PostGIS function AsSVG() <http://svg.cc/pg/assvg/&gt; where I could optimize output by setting relative coords and limit precision.

True, a WMS output format receives a MapContext definitions, that
do in turn have FeatureSource object. A good output format must not
make assumptions on the backend, and the PostGIS data store won't allow
you to make use of that function either.
Then again, you can use the GeoTools Decimator class to perform
a simple on the fly generalization (that class assumes you're using
a special coordinate sequence class for your geometries, we can
talk details about this in a separate mail).

Okay so I guess I will just have to use external tools to make some nicer SVG Data instead of letting PostGIS make all the work, which I thought would be faster than doing it in Java. PostGIS also has the Simplify function which does the generalization. It would be nice, if we could talk about the Decimators generalization in separate mail as you suggested Andrea. It sounds as if I also could use this class to convert the geo data to my local screen device coordinate system, so the client does not neet to do calculations?

4) For my purpose I guess I would use SVG Basic instead of Tiny because Tiny profile does not support textpath element which is nice for street names.
5) A gzip output would also be nice to reduce the file size

This is handled automatically by GeoServer already. There is a
filter installed in GeoServer that compresses text based outputs
on the fly. You just have to add the svg mime type (image/svg+xml)
to the list of compressed types, look into web.xml.

Great, works fine.

6) Since I need a lot of map data to test navigation I would like to import OSM data (OpenStreetMap) into the PostGIS database. I know the tables of OSM are a mess

I have to correct myself. The data povided by GeoFabrik is pretty nice. When I used a tool osm2psql it imported the whole table structure. THe GeoFabrik data is very simple.

Cheers
Ivo

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Chris Holmes
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi,

On 25.11.2008, at 03:16, Chris Holmes wrote:

OpenGeo is doing some RnD on iphone stuff for OpenLayers, trying to build a community of everyone trying to get OL on the iPhone. See the posts on http://docs.opengeo.org/geospiel/ And email list at http://www.openplans.org/projects/iol/lists/iol-discussion

I saw this when I started researching for my project and whit@anonymised.com also pointed me on that project. I would really go into it more deeply, but I don’t have timee, since my project will focus on SDAZ zooming capabilities on the iPhone. For an example video on a dektop see here:

http://www-ui.is.s.u-tokyo.ac.jp/~takeo/video/autozoom.mov

I am afraid, that the doing all the logics with OL and JavaScript will make things too slow. So I will concentrate on small and easy to render SVG files.

One more point on not using PostGIS asSVG() is that it won’t pick up the styling that you’ve defined for your layer in GeoServer. Of course only the batik svg one does that now.

AsSVG does not produce the final SVG output. It just produces the coordinates (relative or abs) with given precision, so one could easily still do style afterwards. But I see that the SVG renderer already uses relative coords, so I don’t see a need for AsSVG anymore.

The ideal svg output format would likely end up being similar to the KML one. Both are XML outputs that should use styling. Ideally we’d have a nice refactoring that lets them share good code, and also share code with the non-XML formats, as there is now some code replication.

of course, that would be the best solution, but as I said, unfortunately I don’t have so much time for spending on this subject.

For ‘tiling’, the ideal solution would be to do something like we’ve done in KML, with GWC, for ‘super overlays’. See http://geoserver.org/display/GEOS/Vector+Super+Overlays GeoServer figures out which data to return first, and GWC caches it all at the right level. I could see it being adapted to SVG in a nice way, to stream in data as users zoom in. Of course it’s a non-trivial amount of work, but it would be quite cool. I think there’s a lot of potential directions it could go, like incorporating generalization and the like.

that was a very good hint, thank you.Especially the different approaches for deciding if a feature should be rendered or not will be usefull.

But yeah, an improved SVG output format for GeoServer would be a great improvement, even without all the super advanced stuff.

yes, absolutely. We will see what I can do. At the moment I will concentrate on the small SVG output. And if time allows afterwards on the SVG cache, if not, I will just precache the tiles in my client, even though they might be ugly on the tile-edges…

cheers
ivo