[OpenLayers-Users] loading heavy WFS. solutions?

Alexandre Dube adube at mapgears.com
Thu Sep 18 09:05:01 EDT 2008


I had the same problem of loading a heavy WFS layer and didn't want to 
use WMS as an alternate solution because I wanted to change the opacity 
when over a feature.

The features are polygons.  I use mapserver with shapefiles.  I wrote a 
little script using phpmapscript which loads a given shapefile, get each 
polygon and for a given a scale ( which gives a resolution ) get each 
point in each polygon and compare the distance between them one by one.  
If the distance is shorter than the resolution ( i.e. if the two points 
are in the same pixel ) I skip the second point and check the next one.  
If not, I add the second point ( it becomes the first ) and go the the 
next one.

The result generates a new shorter shapefile to be used for the given 
scale.  I did that for 5 different scales so in OL I have 5 differents 
layers that only shows data when they are in their range.  I hid them 
from the layerswitcher, created a dummy layer that interacts for both 5 
of them instead.  I works great, but I haven't done much yet so I have 
to do many operations manually ( like, editing the mapfile to add each 
the new layer... )

I compressed the data even more by changing the (1 point / pixel) by (1 
point / 3 pixels).  The result gives a shorter file, a faster loading 
time and gives a smoother image.

Cheers,

Alexandre

G. Allegri wrote:
> Mmm, as I was expecting it's not a good solution for polygons. The
> simplification removes the little ones, and it's ok, but it returns a
> lot of holes along the polygon boundaries, as it doesn't preserve a
> topological coherence. I hope the next release of PostGIS will
> integrate the topology suite (at the moment in beta version).
>
> 2008/9/18 G. Allegri <giohappy at gmail.com>:
>   
>> I was doing it right now :-)
>> I was blocked by a problem while I was creating a view for the
>> simplified geometries. The simplify alone works fine, but with the
>> create view statement it returns empty... But this is something for
>> the PostGIS ML.
>>
>> Thanks anyway for sharing the URL.
>>
>> 2008/9/18 percy <bjpd at pdx.edu>:
>>     
>>> I haven't tried this with WFS, but...
>>>
>>> I display "simplified" geometry when zoomed out with geologic map polygons.
>>>
>>> I use the PostGIS simplify(the_geom, $vertex_density) command to generate
>>> polygons with only one vertex every 500m, for example, when zoomed out past
>>> a certain extent. This is served via Mapserver using minscale/maxscale
>>> settings at the layer level.
>>>
>>> You can create different columns of simplified geometries for use at
>>> different scales (thegeom_2M, thegeom_500K, etc) in PostGIS. Or you can
>>> process the data and spit out different shapefiles for each scale range.
>>>
>>> Sometimes I can see some artifacts of the simplification, since topology
>>> constraints are not part of the process. It has a little "jagginess" like
>>> stained glass, but when you zoom in to see what the artifact is, I have
>>> substituted the high-res data and it's no longer there!
>>> :-)
>>>
>>> I'm pretty sure this approach will work for what you want to do. You can see
>>> a non-openlayers version of this here: http://ogdc.geos.pdx.edu/
>>>
>>> Cheers,
>>> Percy
>>>
>>> G. Allegri wrote:
>>>       
>>>> Hi list,
>>>> I need to load a heavy GML (the original shapefile is >12 MB), and I
>>>> can't make any simplification, beacuse it's composed by little,
>>>> needed, polygons.
>>>> Has ever been experimented something to do a sort of "pyramids" with
>>>> vectorial features? The only solution I can imagine is to produce
>>>> various simplifications, and then call different GMLs on the base of
>>>> the zoom factor... Well, it isn't a solution, it would be just a
>>>> horrible workaround!
>>>>
>>>> Any idea to share?
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>>
>>>>         
>>> --
>>> David Percy
>>> Geospatial Data Manager
>>> Geology Department
>>> Portland State University
>>> http://gisgeek.pdx.edu
>>> 503-725-3373
>>>
>>>       
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list