[Geoserver-users] Different features at different zoom levels

Hi,

This might not fit well in this mailing list, but there it goes...

I am trying to use Google Maps to display the features of my WFS Geoserver service... you can take a look at http://hq6.grinfo.net:8080/geoserver/gmap/singer_wfs.html

The Javascript in this page is dynamically querying the WFS service to retrieve the features (only points in my case) for the bounding box that the user is at(also it makes possible to query the WFS, but this is another story).

The only problem I have is that my WFS has too many features, therefore when you are viewing a large area too many features are retrieved and the client gets very slow. If I limit the number of features to say 100 (in Geoserver or in the WFS request) it is fine, but the feature only appear at the bottom of the map. This is probably because of the index in the PostGIS database that start retrieving features with lower latitudes and then it stops.
This creates a very ugly map because it looks like if all features are always at the bottom.
Therefore I started looking for some kind of clustering mechanism and found one being done in the client (javascript in the web browser) so all these features are retrieved and then grouped and only some dots are shown, but this is still very slow and does not scale... (this is the status of the interface right now)

So, now it looks to me, that the only way to go is to do this clustering of features in the server. therefore I was wondering if someone had already done something like this. The idea is to retrieve different features at different "zoom levels".

The perfect situation would be that the server is able to returned me always only 50 features, some of then being "clusters" (groups of features) and features. Also would be great if these features are somehow distributed around the whole map and not only at the bottom...

Thanks in advance for any help.

Javier.

PD: I am also playing with WMS service to overlay Google Maps... but I am still on an early stage. I need to be able to calculate the X and Y when a user clicks somewhere in the google maps to be able to do a gefinfo request to the WMS... You can find it at:
http://hq6.grinfo.net:8080/geoserver/gmap/singer_wms.html

Quoting Javier de la Torre <jatorre@anonymised.com>:

Hi,

This might not fit well in this mailing list, but there it goes...

This fits perfectly, in my mind, I think this list should be, among
other things, a discussion forum for what one actually _does_ with
GeoServer, and google maps integration is something I'd really like to
see. Indeed it'd be great if you could write up your work when you're
done in the clients section, perhaps even a tutorial with examples of
how others can easily get geoserver working with google maps. Try to
take good notes.

As for what you say, the problem is that WFS was not designed for
display. It's to get the raw data. The recommended approach is to use
WMS, and then use WFS for queries of data. I would highly recommend
that over using getfeatureinfo, as that feature of WMS is sort of
hacky, the html is in whatever form the server likes, and the tolerance
on the x,y click is also just up to server implementation. With a WFS
GetFeature you can specify the exact bounds of a given point click, and
do much more advanced filtering. In the WMS you can use SLD with
min/max scale denominators, so it only renders things when you're
zoomed in, basically exactly what you're looking for.

That said, it is nice to be able to use the WFS with Google Maps, since
you can turn the features into the nice little icons and click on them,
something you can't do with the WMS. One approach could be to define a
zoom level, as an attribute of your data. You could make use of it in
the WMS as well, use filters against the zoom level instead of the
Min/Max denominator.

This isn't quite as good as the 'clustering' approach, since you have to
basically define your clusters beforehand. Another approach could
possibly be to define like a custom Filter (or perhaps a Function,
since they are easier for us to define custom ones, though I don't know
if it'd be sufficient). I'm not quite sure how exactly it would work,
but I think that'd be the most spec compliant way to go about it. The
implementation might be a bit tricky though.

A sort of half way measure could be to do a hybrid wms/wfs - query the
wfs with the number of 'hits' (wfs 1.1 lets you just return the number
of features it would return, would need to be implemented in geoserver
but should be trivial to do so - if you need a hack to do it I could do
it in an hour or less). If the hits is greater than your threshold,
then call the WMS to render. If it's less then call the WFS and do the
gmaps rendering.

Hope this may help a bit, do try to take a section of the wiki and write
up what you come up with, even if it's just rough notes that someone
else can clean up later.

Chris

I am trying to use Google Maps to display the features of my WFS
Geoserver service... you can take a look at http://hq6.grinfo.net:
8080/geoserver/gmap/singer_wfs.html

The Javascript in this page is dynamically querying the WFS service
to retrieve the features (only points in my case) for the bounding
box that the user is at(also it makes possible to query the WFS, but
this is another story).

The only problem I have is that my WFS has too many features,
therefore when you are viewing a large area too many features are
retrieved and the client gets very slow. If I limit the number of
features to say 100 (in Geoserver or in the WFS request) it is fine,
but the feature only appear at the bottom of the map. This is
probably because of the index in the PostGIS database that start
retrieving features with lower latitudes and then it stops.
This creates a very ugly map because it looks like if all features
are always at the bottom.
Therefore I started looking for some kind of clustering mechanism and
found one being done in the client (javascript in the web browser) so
all these features are retrieved and then grouped and only some dots
are shown, but this is still very slow and does not scale... (this is
the status of the interface right now)

So, now it looks to me, that the only way to go is to do this
clustering of features in the server. therefore I was wondering if
someone had already done something like this. The idea is to retrieve
different features at different "zoom levels".

The perfect situation would be that the server is able to returned me
always only 50 features, some of then being "clusters" (groups of
features) and features. Also would be great if these features are
somehow distributed around the whole map and not only at the
bottom...

Thanks in advance for any help.

Javier.

PD: I am also playing with WMS service to overlay Google Maps... but
I am still on an early stage. I need to be able to calculate the X
and Y when a user clicks somewhere in the google maps to be able to
do a gefinfo request to the WMS... You can find it at:
http://hq6.grinfo.net:8080/geoserver/gmap/singer_wms.html

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through
log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

----------------------------------------------------------
This mail sent through IMP: https://webmail.limegroup.com/

Hi Chris,

Nice to hear from you again.

This fits perfectly, in my mind, I think this list should be, among
other things, a discussion forum for what one actually _does_ with
GeoServer, and google maps integration is something I'd really like to
see. Indeed it'd be great if you could write up your work when you're
done in the clients section, perhaps even a tutorial with examples of
how others can easily get geoserver working with google maps. Try to
take good notes.

Ok, I will try my best to spend some time when I finish, this week, in writing some text about what I have done so far, (Together on how to install Geoserver on Mac os X that I still have pending!).

As for what you say, the problem is that WFS was not designed for
display. It's to get the raw data. The recommended approach is to use
WMS, and then use WFS for queries of data. I would highly recommend
that over using getfeatureinfo, as that feature of WMS is sort of
hacky, the html is in whatever form the server likes, and the tolerance
on the x,y click is also just up to server implementation. With a WFS
GetFeature you can specify the exact bounds of a given point click, and
do much more advanced filtering. In the WMS you can use SLD with
min/max scale denominators, so it only renders things when you're
zoomed in, basically exactly what you're looking for.

For the time being I have mixed WMS and WFS. You can try it at:

http://hq6.grinfo.net:8080/geoserver/gmap/singer_wms.html

Getting the features by bounding box is really easy and it really works great. Of course, after some time playing with the tolerance at different zoom levels.

The biggest problem I have now with it is the performance at big zooms, let say the whole world. Geoserver needs to take all features from the database and create the images... I suppose I could consider some caching to improve this, but I did not spend much time considering this...
Is there any solution out of the box from Geoserver :wink: Would be great!

I think it could be considered to include a Google maps demonstrator with Geoserver. Let say that the user has to write the Google Maps API somewhere in the config tool and this mashup is already ready to be used... or maybe you could create a new section on the config tool to configure clients, like the one for Google Map...
  It is really nice to have some out of the box clients already set up after installing Geoserver :slight_smile:

A sort of half way measure could be to do a hybrid wms/wfs - query the
wfs with the number of 'hits' (wfs 1.1 lets you just return the number
of features it would return, would need to be implemented in geoserver
but should be trivial to do so - if you need a hack to do it I could do
it in an hour or less). If the hits is greater than your threshold,
then call the WMS to render. If it's less then call the WFS and do the
gmaps rendering.

Uhmm, for the time being I am happuy with the results like they are now. Geoserver is really fast answering for a Getfeature with a little bounding box so for the user it looks like if the data was already available... so I think this is enough..

What could be interesting is to create a new operation called scan or inventory or something like this, to be able to retrieve the "distinct" features for a certain query/ response format... I think this is not in the OGC standards, but it is quite useful when creating interfaces...

Hope this may help a bit, do try to take a section of the wiki and write
up what you come up with, even if it's just rough notes that someone
else can clean up later.

I promise to do so next weekend!

Javier.