Rahkonen Jukka | 10 Feb 16:12
Picon

Does Mapserver utilise Spatialite spatial index correctly?

Hi,
 
GDAL was made to utilise Spatialite spatial index effectively if it exists with ticket
After this change ogr2ogr with -spat bounding box query is much faster.  However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the rendering speed of Spatialite data with Mapserver is pretty slow. It is evenly slow when zoomed out and zoomed in which makes me believe that the spatial index is perhaps not used.
 
Could it be that Mapserver does not utilise the improved method that was implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?
 
-Jukka Rahkonen-
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Lime, Steve D (DNR | 10 Feb 16:17
Picon
Picon
Favicon

RE: Does Mapserver utilise Spatialite spatial index correctly?

There is no native support for Spatialite in MapServer, it's all through GDAL/OGR.

Steve

From: mapserver-users-bounces <at> lists.osgeo.org [mapserver-users-bounces <at> lists.osgeo.org] on behalf of Rahkonen Jukka [Jukka.Rahkonen <at> mmmtike.fi]
Sent: Friday, February 10, 2012 9:12 AM
To: 'mapserver-users <at> lists.osgeo.org'
Subject: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

Hi,
 
GDAL was made to utilise Spatialite spatial index effectively if it exists with ticket
After this change ogr2ogr with -spat bounding box query is much faster.  However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the rendering speed of Spatialite data with Mapserver is pretty slow. It is evenly slow when zoomed out and zoomed in which makes me believe that the spatial index is perhaps not used.
 
Could it be that Mapserver does not utilise the improved method that was implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?
 
-Jukka Rahkonen-
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Rahkonen Jukka | 10 Feb 16:36
Picon

Re: Does Mapserver utilise Spatialite spatial index correctly?

Hi,
 
OK, lets put it this way:
Is it sure that Mapserver is firing the BBOX query so that GDAL/OGR understands to follow the path that is implemented in http://trac.osgeo.org/gdal/changeset/23008
instead of making an inefficient MBRIntersects()  query or some other slow query?
 
I do not believe that a user like me has a possibility to check what really happens with Spatialite like I can do with PostGIS and Oracle because Spatialite does not collect a log file.
 
-Jukka Rahkonen-
 
Lime, Steve D (DNR)  wrote:
There is no native support for Spatialite in MapServer, it's all through GDAL/OGR.

Steve

From: mapserver-users-bounces <at> lists.osgeo.org [mapserver-users-bounces <at> lists.osgeo.org] on behalf of Rahkonen Jukka [Jukka.Rahkonen <at> mmmtike.fi]
Sent: Friday, February 10, 2012 9:12 AM
To: 'mapserver-users <at> lists.osgeo.org'
Subject: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

Hi,
 
GDAL was made to utilise Spatialite spatial index effectively if it exists with ticket
After this change ogr2ogr with -spat bounding box query is much faster.  However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the rendering speed of Spatialite data with Mapserver is pretty slow. It is evenly slow when zoomed out and zoomed in which makes me believe that the spatial index is perhaps not used.
 
Could it be that Mapserver does not utilise the improved method that was implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?
 
-Jukka Rahkonen-
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Lime, Steve D (DNR | 10 Feb 17:45
Picon
Picon
Favicon

RE: Does Mapserver utilise Spatialite spatial index correctly?

The changeset in OGR is in the spatialite driver so it doesn’t look like a program using the OGR APIs would need to do anything special. Someone familiar with the OGR driver will have to weigh in I suspect…

 

Steve

 

From: mapserver-users-bounces <at> lists.osgeo.org [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Rahkonen Jukka
Sent: Friday, February 10, 2012 9:36 AM
To: 'mapserver-users <at> lists.osgeo.org'
Subject: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

 

Hi,

 

OK, lets put it this way:

Is it sure that Mapserver is firing the BBOX query so that GDAL/OGR understands to follow the path that is implemented in http://trac.osgeo.org/gdal/changeset/23008

instead of making an inefficient MBRIntersects()  query or some other slow query?

 

I do not believe that a user like me has a possibility to check what really happens with Spatialite like I can do with PostGIS and Oracle because Spatialite does not collect a log file.

 

-Jukka Rahkonen-

 

Lime, Steve D (DNR)  wrote:

There is no native support for Spatialite in MapServer, it's all through GDAL/OGR.

Steve

From: mapserver-users-bounces <at> lists.osgeo.org [mapserver-users-bounces <at> lists.osgeo.org] on behalf of Rahkonen Jukka [Jukka.Rahkonen <at> mmmtike.fi]
Sent: Friday, February 10, 2012 9:12 AM
To: 'mapserver-users <at> lists.osgeo.org'
Subject: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

Hi,

 

GDAL was made to utilise Spatialite spatial index effectively if it exists with ticket

After this change ogr2ogr with -spat bounding box query is much faster.  However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the rendering speed of Spatialite data with Mapserver is pretty slow. It is evenly slow when zoomed out and zoomed in which makes me believe that the spatial index is perhaps not used.

 

Could it be that Mapserver does not utilise the improved method that was implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?

 

-Jukka Rahkonen-

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Even Rouault | 10 Feb 18:05

RE: Does Mapserver utilise Spatialite spatial index correctly?

Selon "Lime, Steve D (DNR)" <Steve.Lime <at> state.mn.us>:

> The changeset in OGR is in the spatialite driver so it doesn't look like a
> program using the OGR APIs would need to do anything special. Someone
> familiar with the OGR driver will have to weigh in I suspect...

Does the OGR backend of MapServer always use OGR_L_SetSpatialFilter() ? I've not
MapServer source code under my eyes right now, but I'm wondering if there's not
a different code path according to if you specify in the mapfile a OGR layer
name or a OGR SQL.

>
> Steve
>
> From: mapserver-users-bounces <at> lists.osgeo.org
> [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Rahkonen Jukka
> Sent: Friday, February 10, 2012 9:36 AM
> To: 'mapserver-users <at> lists.osgeo.org'
> Subject: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial
> index correctly?
>
> Hi,
>
> OK, lets put it this way:
> Is it sure that Mapserver is firing the BBOX query so that GDAL/OGR
> understands to follow the path that is implemented in
> http://trac.osgeo.org/gdal/changeset/23008
> instead of making an inefficient MBRIntersects()  query or some other slow
> query?
>
> I do not believe that a user like me has a possibility to check what really
> happens with Spatialite like I can do with PostGIS and Oracle because
> Spatialite does not collect a log file.
>
> -Jukka Rahkonen-
>
> Lime, Steve D (DNR)  wrote:
> There is no native support for Spatialite in MapServer, it's all through
> GDAL/OGR.
>
> Steve
> ________________________________
> From: mapserver-users-bounces <at> lists.osgeo.org
> [mapserver-users-bounces <at> lists.osgeo.org] on behalf of Rahkonen Jukka
> [Jukka.Rahkonen <at> mmmtike.fi]
> Sent: Friday, February 10, 2012 9:12 AM
> To: 'mapserver-users <at> lists.osgeo.org'
> Subject: [mapserver-users] Does Mapserver utilise Spatialite spatial index
> correctly?
> Hi,
>
> GDAL was made to utilise Spatialite spatial index effectively if it exists
> with ticket
> http://trac.osgeo.org/gdal/ticket/4212
> After this change ogr2ogr with -spat bounding box query is much faster.
> However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the
> rendering speed of Spatialite data with Mapserver is pretty slow. It is
> evenly slow when zoomed out and zoomed in which makes me believe that the
> spatial index is perhaps not used.
>
> Could it be that Mapserver does not utilise the improved method that was
> implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?
>
> -Jukka Rahkonen-
>

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Rahkonen Jukka | 11 Feb 10:08
Picon

Re: Does Mapserver utilise Spatialite spatial index correctly?

Hi,

Sorry about long message but I like pretty much about the idea to be able to send Mapserver, mapfiles and data
in one single package so that the end user would only need to unzip, launch Mapserver and enjoy. With the
package like the one I am pointing later in this message it is already possible, but the resulting service
is not fast enough. However, GDAL is pretty fast with Spatialite so I believe and hope that there is just
some minory thing to adjust on the Mapserver side for making it ten times faster with Spatialite than it is now.

I prepared a package for demonstrating why I believe that Mapserver does not make queries in the best
possible way.

The package is rather big because it contains the whole MS4W 3.0.4beta1 and mapfiles and a Spatilite
database from OpenStreetMap data. It is ready to use on Windows after doing these steps:

- Dowload from http://latuviitta.org/documents/MS_GDAL_Spatialite_test.zip
- Unzip to a root of any disk drive
- Open a command window, go to [disk_letter]:\ms4w\apache\bin and give command "httpd"

First, make a query with ogrinfo. GDAL 1.9.0 is included in the package, just go to \ms4w\ first and run the
setenv.bat first.

D:\ms4w\data>ogrinfo -so berlin.sqlite osm_line -spat 1496458.316816 6889766.373
154 1497120.112054 6890295.209530

This will be pretty fast.

Now send the following url with a browser. It will make Mapserver to query the same layer 

http://localhost:8060/cgi-bin/mapserv.exe?map=/ms4w/osm_maps/osm_wms.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=663&HEIGHT=530&LAYERS=roadsclose_01&TRANSPARENT=TRUE&FORMAT=image%2Fpng&BBOX=1496457.8169701756,6889765.873308353,1497120.611899381,6890295.70937544&SRS=EPSG:3857&STYLES=

I suppose it will take a few seconds before the image is ready.  For me it took 9,1 seconds. Here is the full
listing about what I got into log file with DEBUG 5 

[Sat Feb 11 10:06:00 2012].726000 msOGRFileOpen(\ms4w\data\berlin.sqlite)...
[Sat Feb 11 10:06:00 2012].730000 OGROPen(\ms4w\data\berlin.sqlite)
[Sat Feb 11 10:06:03 2012].732000 msConnPoolRegister(roadsclose_01,\ms4w\data\berlin.sqlite,03771718)
[Sat Feb 11 10:06:06 2012].435000 msOGRFileWhichShapes: Setting spatial filter to 1496458.316816
6889766.373154 1497120.112054 6890295.209530
[Sat Feb 11 10:06:09 2012].52000 msOGRFileNextShape: Returning shape=801, tile=0
[Sat Feb 11 10:06:09 2012].369000 msOGRFileNextShape: Returning shape=29054, tile=0
[Sat Feb 11 10:06:09 2012].371000 msOGRFileNextShape: Returning shape=29154, tile=0
[Sat Feb 11 10:06:09 2012].372000 msOGRFileNextShape: Returning shape=29173, tile=0
[Sat Feb 11 10:06:09 2012].373000 msOGRFileNextShape: Returning shape=29275, tile=0
[Sat Feb 11 10:06:09 2012].377000 msOGRFileNextShape: Returning shape=29483, tile=0
[Sat Feb 11 10:06:09 2012].378000 msOGRFileNextShape: Returning shape=29485, tile=0
[Sat Feb 11 10:06:09 2012].378000 msOGRFileNextShape: Returning shape=29504, tile=0
[Sat Feb 11 10:06:09 2012].379000 msOGRFileNextShape: Returning shape=29579, tile=0
[Sat Feb 11 10:06:09 2012].380000 msOGRFileNextShape: Returning shape=29645, tile=0
[Sat Feb 11 10:06:09 2012].380000 msOGRFileNextShape: Returning shape=29657, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29658, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29674, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29680, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29681, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29695, tile=0
[Sat Feb 11 10:06:09 2012].383000 msOGRFileNextShape: Returning shape=29754, tile=0
[Sat Feb 11 10:06:09 2012].384000 msOGRFileNextShape: Returning shape=29793, tile=0
[Sat Feb 11 10:06:09 2012].385000 msOGRFileNextShape: Returning shape=29802, tile=0
[Sat Feb 11 10:06:09 2012].385000 msOGRFileNextShape: Returning shape=29817, tile=0
[Sat Feb 11 10:06:09 2012].385000 msOGRFileNextShape: Returning shape=29818, tile=0
[Sat Feb 11 10:06:09 2012].386000 msOGRFileNextShape: Returning shape=29819, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29911, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29924, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29926, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29929, tile=0
[Sat Feb 11 10:06:09 2012].388000 msOGRFileNextShape: Returning shape=29955, tile=0
[Sat Feb 11 10:06:09 2012].388000 msOGRFileNextShape: Returning shape=29969, tile=0
[Sat Feb 11 10:06:09 2012].388000 msOGRFileNextShape: Returning shape=29970, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=29972, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=29973, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=29991, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=30022, tile=0
[Sat Feb 11 10:06:09 2012].390000 msOGRFileNextShape: Returning shape=30065, tile=0
[Sat Feb 11 10:06:09 2012].390000 msOGRFileNextShape: Returning shape=30084, tile=0
[Sat Feb 11 10:06:09 2012].392000 msOGRFileNextShape: Returning shape=30174, tile=0
[Sat Feb 11 10:06:09 2012].393000 msOGRFileNextShape: Returning shape=30175, tile=0
[Sat Feb 11 10:06:09 2012].393000 msOGRFileNextShape: Returning shape=30176, tile=0
[Sat Feb 11 10:06:09 2012].394000 msOGRFileNextShape: Returning shape=30198, tile=0
[Sat Feb 11 10:06:09 2012].395000 msOGRFileNextShape: Returning shape=30255, tile=0
[Sat Feb 11 10:06:09 2012].702000 msOGRFileNextShape: Returning shape=57673, tile=0
[Sat Feb 11 10:06:09 2012].707000 msOGRFileNextShape: Returning shape=57891, tile=0
[Sat Feb 11 10:06:09 2012].708000 msOGRFileNextShape: Returning shape=57929, tile=0
[Sat Feb 11 10:06:09 2012].708000 msOGRFileNextShape: Returning shape=57937, tile=0
[Sat Feb 11 10:06:09 2012].709000 msOGRFileNextShape: Returning shape=57938, tile=0
[Sat Feb 11 10:06:09 2012].710000 msOGRFileNextShape: Returning shape=57965, tile=0
[Sat Feb 11 10:06:09 2012].775000 msOGRFileNextShape: Returning shape=62981, tile=0
[Sat Feb 11 10:06:09 2012].862000 msOGRFileNextShape: Returning shape=69883, tile=0
[Sat Feb 11 10:06:09 2012].864000 msOGRFileNextShape: Returning shape=69972, tile=0
[Sat Feb 11 10:06:09 2012].864000 msOGRFileNextShape: Returning shape=69973, tile=0
[Sat Feb 11 10:06:09 2012].869000 msOGRFileNextShape: Returning shape=70356, tile=0
[Sat Feb 11 10:06:09 2012].869000 msOGRFileNextShape: Returning shape=70359, tile=0
[Sat Feb 11 10:06:09 2012].869000 msOGRFileNextShape: Returning shape=70361, tile=0
[Sat Feb 11 10:06:09 2012].874000 msOGRFileNextShape: Returning shape=70781, tile=0
[Sat Feb 11 10:06:09 2012].874000 msOGRFileNextShape: Returning shape=70782, tile=0
[Sat Feb 11 10:06:09 2012].874000 msOGRFileNextShape: Returning shape=70783, tile=0
[Sat Feb 11 10:06:09 2012].888000 msOGRFileNextShape: Returning MS_DONE (no more shapes)
[Sat Feb 11 10:06:09 2012].889000 msOGRLayerClose(\ms4w\data\berlin.sqlite).
[Sat Feb 11 10:06:09 2012].889000 msOGRFileClose(\ms4w\data\berlin.sqlite,-1).
[Sat Feb 11 10:06:09 2012].889000 msConnPoolRelease(roadsclose_01,\ms4w\data\berlin.sqlite,03771718)
[Sat Feb 11 10:06:09 2012].889000 msConnPoolClose(\ms4w\data\berlin.sqlite,03771718)
[Sat Feb 11 10:06:09 2012].898000 msDrawMap(): Layer 16 (roadsclose_01), 9.174s
[Sat Feb 11 10:06:10 2012].3000 freeLayer(): freeing layer at 036FF3F8.

-Jukka Rahkonen-

________________________________________
Lähettäjä: Even Rouault [even.rouault <at> mines-paris.org]
Lähetetty: 10. helmikuuta 2012 19:05
Vastaanottaja: Lime, Steve D (DNR)
Kopio: Rahkonen Jukka; 'mapserver-users <at> lists.osgeo.org'
Aihe: RE: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

Selon "Lime, Steve D (DNR)" <Steve.Lime <at> state.mn.us>:

> The changeset in OGR is in the spatialite driver so it doesn't look like a
> program using the OGR APIs would need to do anything special. Someone
> familiar with the OGR driver will have to weigh in I suspect...

Does the OGR backend of MapServer always use OGR_L_SetSpatialFilter() ? I've not
MapServer source code under my eyes right now, but I'm wondering if there's not
a different code path according to if you specify in the mapfile a OGR layer
name or a OGR SQL.

>
> Steve
>
> From: mapserver-users-bounces <at> lists.osgeo.org
> [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Rahkonen Jukka
> Sent: Friday, February 10, 2012 9:36 AM
> To: 'mapserver-users <at> lists.osgeo.org'
> Subject: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial
> index correctly?
>
> Hi,
>
> OK, lets put it this way:
> Is it sure that Mapserver is firing the BBOX query so that GDAL/OGR
> understands to follow the path that is implemented in
> http://trac.osgeo.org/gdal/changeset/23008
> instead of making an inefficient MBRIntersects()  query or some other slow
> query?
>
> I do not believe that a user like me has a possibility to check what really
> happens with Spatialite like I can do with PostGIS and Oracle because
> Spatialite does not collect a log file.
>
> -Jukka Rahkonen-
>
> Lime, Steve D (DNR)  wrote:
> There is no native support for Spatialite in MapServer, it's all through
> GDAL/OGR.
>
> Steve
> ________________________________
> From: mapserver-users-bounces <at> lists.osgeo.org
> [mapserver-users-bounces <at> lists.osgeo.org] on behalf of Rahkonen Jukka
> [Jukka.Rahkonen <at> mmmtike.fi]
> Sent: Friday, February 10, 2012 9:12 AM
> To: 'mapserver-users <at> lists.osgeo.org'
> Subject: [mapserver-users] Does Mapserver utilise Spatialite spatial index
> correctly?
> Hi,
>
> GDAL was made to utilise Spatialite spatial index effectively if it exists
> with ticket
> http://trac.osgeo.org/gdal/ticket/4212
> After this change ogr2ogr with -spat bounding box query is much faster.
> However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the
> rendering speed of Spatialite data with Mapserver is pretty slow. It is
> evenly slow when zoomed out and zoomed in which makes me believe that the
> spatial index is perhaps not used.
>
> Could it be that Mapserver does not utilise the improved method that was
> implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?
>
> -Jukka Rahkonen-
>

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Rahkonen Jukka | 11 Feb 11:42
Picon

Re: Does Mapserver utilise Spatialite spatial index correctly?

Hi,

Perhaps it is not the spatial index at all, or it is not the most important part? It looks like OGR is using
Spatialite through a connection pool and creating a new connection and pool is pretty heavy.  A first aid
with a map with many layers is to use PROCESSING "CLOSE_CONNECTION=DEFER" even when running Mapserver as
cgi.  It can save a couple of seconds per layer which makes a very big difference with the OSM default WMS
group (from 40 sec to 10 sec) . However, "CLOSE_CONNECTION=DEFER" cannot help with the pretty slow
initial time but it would need some other kind of optimisation.

-Jukka-
________________________________________
Lähettäjä: mapserver-users-bounces <at> lists.osgeo.org
[mapserver-users-bounces <at> lists.osgeo.org] k&#228;ytt&#228;j&#228;n Rahkonen Jukka
[Jukka.Rahkonen <at> mmmtike.fi] puolesta
Lähetetty: 11. helmikuuta 2012 11:08
Vastaanottaja: Even Rouault; Lime, Steve D (DNR)
Kopio: 'mapserver-users <at> lists.osgeo.org'
Aihe: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial   index correctly?

Hi,

Sorry about long message but I like pretty much about the idea to be able to send Mapserver, mapfiles and data
in one single package so that the end user would only need to unzip, launch Mapserver and enjoy. With the
package like the one I am pointing later in this message it is already possible, but the resulting service
is not fast enough. However, GDAL is pretty fast with Spatialite so I believe and hope that there is just
some minory thing to adjust on the Mapserver side for making it ten times faster with Spatialite than it is now.

I prepared a package for demonstrating why I believe that Mapserver does not make queries in the best
possible way.

The package is rather big because it contains the whole MS4W 3.0.4beta1 and mapfiles and a Spatilite
database from OpenStreetMap data. It is ready to use on Windows after doing these steps:

- Dowload from http://latuviitta.org/documents/MS_GDAL_Spatialite_test.zip
- Unzip to a root of any disk drive
- Open a command window, go to [disk_letter]:\ms4w\apache\bin and give command "httpd"

First, make a query with ogrinfo. GDAL 1.9.0 is included in the package, just go to \ms4w\ first and run the
setenv.bat first.

D:\ms4w\data>ogrinfo -so berlin.sqlite osm_line -spat 1496458.316816 6889766.373
154 1497120.112054 6890295.209530

This will be pretty fast.

Now send the following url with a browser. It will make Mapserver to query the same layer

http://localhost:8060/cgi-bin/mapserv.exe?map=/ms4w/osm_maps/osm_wms.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=663&HEIGHT=530&LAYERS=roadsclose_01&TRANSPARENT=TRUE&FORMAT=image%2Fpng&BBOX=1496457.8169701756,6889765.873308353,1497120.611899381,6890295.70937544&SRS=EPSG:3857&STYLES=

I suppose it will take a few seconds before the image is ready.  For me it took 9,1 seconds. Here is the full
listing about what I got into log file with DEBUG 5

[Sat Feb 11 10:06:00 2012].726000 msOGRFileOpen(\ms4w\data\berlin.sqlite)...
[Sat Feb 11 10:06:00 2012].730000 OGROPen(\ms4w\data\berlin.sqlite)
[Sat Feb 11 10:06:03 2012].732000 msConnPoolRegister(roadsclose_01,\ms4w\data\berlin.sqlite,03771718)
[Sat Feb 11 10:06:06 2012].435000 msOGRFileWhichShapes: Setting spatial filter to 1496458.316816
6889766.373154 1497120.112054 6890295.209530
[Sat Feb 11 10:06:09 2012].52000 msOGRFileNextShape: Returning shape=801, tile=0
[Sat Feb 11 10:06:09 2012].369000 msOGRFileNextShape: Returning shape=29054, tile=0
[Sat Feb 11 10:06:09 2012].371000 msOGRFileNextShape: Returning shape=29154, tile=0
[Sat Feb 11 10:06:09 2012].372000 msOGRFileNextShape: Returning shape=29173, tile=0
[Sat Feb 11 10:06:09 2012].373000 msOGRFileNextShape: Returning shape=29275, tile=0
[Sat Feb 11 10:06:09 2012].377000 msOGRFileNextShape: Returning shape=29483, tile=0
[Sat Feb 11 10:06:09 2012].378000 msOGRFileNextShape: Returning shape=29485, tile=0
[Sat Feb 11 10:06:09 2012].378000 msOGRFileNextShape: Returning shape=29504, tile=0
[Sat Feb 11 10:06:09 2012].379000 msOGRFileNextShape: Returning shape=29579, tile=0
[Sat Feb 11 10:06:09 2012].380000 msOGRFileNextShape: Returning shape=29645, tile=0
[Sat Feb 11 10:06:09 2012].380000 msOGRFileNextShape: Returning shape=29657, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29658, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29674, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29680, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29681, tile=0
[Sat Feb 11 10:06:09 2012].381000 msOGRFileNextShape: Returning shape=29695, tile=0
[Sat Feb 11 10:06:09 2012].383000 msOGRFileNextShape: Returning shape=29754, tile=0
[Sat Feb 11 10:06:09 2012].384000 msOGRFileNextShape: Returning shape=29793, tile=0
[Sat Feb 11 10:06:09 2012].385000 msOGRFileNextShape: Returning shape=29802, tile=0
[Sat Feb 11 10:06:09 2012].385000 msOGRFileNextShape: Returning shape=29817, tile=0
[Sat Feb 11 10:06:09 2012].385000 msOGRFileNextShape: Returning shape=29818, tile=0
[Sat Feb 11 10:06:09 2012].386000 msOGRFileNextShape: Returning shape=29819, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29911, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29924, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29926, tile=0
[Sat Feb 11 10:06:09 2012].387000 msOGRFileNextShape: Returning shape=29929, tile=0
[Sat Feb 11 10:06:09 2012].388000 msOGRFileNextShape: Returning shape=29955, tile=0
[Sat Feb 11 10:06:09 2012].388000 msOGRFileNextShape: Returning shape=29969, tile=0
[Sat Feb 11 10:06:09 2012].388000 msOGRFileNextShape: Returning shape=29970, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=29972, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=29973, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=29991, tile=0
[Sat Feb 11 10:06:09 2012].389000 msOGRFileNextShape: Returning shape=30022, tile=0
[Sat Feb 11 10:06:09 2012].390000 msOGRFileNextShape: Returning shape=30065, tile=0
[Sat Feb 11 10:06:09 2012].390000 msOGRFileNextShape: Returning shape=30084, tile=0
[Sat Feb 11 10:06:09 2012].392000 msOGRFileNextShape: Returning shape=30174, tile=0
[Sat Feb 11 10:06:09 2012].393000 msOGRFileNextShape: Returning shape=30175, tile=0
[Sat Feb 11 10:06:09 2012].393000 msOGRFileNextShape: Returning shape=30176, tile=0
[Sat Feb 11 10:06:09 2012].394000 msOGRFileNextShape: Returning shape=30198, tile=0
[Sat Feb 11 10:06:09 2012].395000 msOGRFileNextShape: Returning shape=30255, tile=0
[Sat Feb 11 10:06:09 2012].702000 msOGRFileNextShape: Returning shape=57673, tile=0
[Sat Feb 11 10:06:09 2012].707000 msOGRFileNextShape: Returning shape=57891, tile=0
[Sat Feb 11 10:06:09 2012].708000 msOGRFileNextShape: Returning shape=57929, tile=0
[Sat Feb 11 10:06:09 2012].708000 msOGRFileNextShape: Returning shape=57937, tile=0
[Sat Feb 11 10:06:09 2012].709000 msOGRFileNextShape: Returning shape=57938, tile=0
[Sat Feb 11 10:06:09 2012].710000 msOGRFileNextShape: Returning shape=57965, tile=0
[Sat Feb 11 10:06:09 2012].775000 msOGRFileNextShape: Returning shape=62981, tile=0
[Sat Feb 11 10:06:09 2012].862000 msOGRFileNextShape: Returning shape=69883, tile=0
[Sat Feb 11 10:06:09 2012].864000 msOGRFileNextShape: Returning shape=69972, tile=0
[Sat Feb 11 10:06:09 2012].864000 msOGRFileNextShape: Returning shape=69973, tile=0
[Sat Feb 11 10:06:09 2012].869000 msOGRFileNextShape: Returning shape=70356, tile=0
[Sat Feb 11 10:06:09 2012].869000 msOGRFileNextShape: Returning shape=70359, tile=0
[Sat Feb 11 10:06:09 2012].869000 msOGRFileNextShape: Returning shape=70361, tile=0
[Sat Feb 11 10:06:09 2012].874000 msOGRFileNextShape: Returning shape=70781, tile=0
[Sat Feb 11 10:06:09 2012].874000 msOGRFileNextShape: Returning shape=70782, tile=0
[Sat Feb 11 10:06:09 2012].874000 msOGRFileNextShape: Returning shape=70783, tile=0
[Sat Feb 11 10:06:09 2012].888000 msOGRFileNextShape: Returning MS_DONE (no more shapes)
[Sat Feb 11 10:06:09 2012].889000 msOGRLayerClose(\ms4w\data\berlin.sqlite).
[Sat Feb 11 10:06:09 2012].889000 msOGRFileClose(\ms4w\data\berlin.sqlite,-1).
[Sat Feb 11 10:06:09 2012].889000 msConnPoolRelease(roadsclose_01,\ms4w\data\berlin.sqlite,03771718)
[Sat Feb 11 10:06:09 2012].889000 msConnPoolClose(\ms4w\data\berlin.sqlite,03771718)
[Sat Feb 11 10:06:09 2012].898000 msDrawMap(): Layer 16 (roadsclose_01), 9.174s
[Sat Feb 11 10:06:10 2012].3000 freeLayer(): freeing layer at 036FF3F8.

-Jukka Rahkonen-

________________________________________
Lähettäjä: Even Rouault [even.rouault <at> mines-paris.org]
Lähetetty: 10. helmikuuta 2012 19:05
Vastaanottaja: Lime, Steve D (DNR)
Kopio: Rahkonen Jukka; 'mapserver-users <at> lists.osgeo.org'
Aihe: RE: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

Selon "Lime, Steve D (DNR)" <Steve.Lime <at> state.mn.us>:

> The changeset in OGR is in the spatialite driver so it doesn't look like a
> program using the OGR APIs would need to do anything special. Someone
> familiar with the OGR driver will have to weigh in I suspect...

Does the OGR backend of MapServer always use OGR_L_SetSpatialFilter() ? I've not
MapServer source code under my eyes right now, but I'm wondering if there's not
a different code path according to if you specify in the mapfile a OGR layer
name or a OGR SQL.

>
> Steve
>
> From: mapserver-users-bounces <at> lists.osgeo.org
> [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Rahkonen Jukka
> Sent: Friday, February 10, 2012 9:36 AM
> To: 'mapserver-users <at> lists.osgeo.org'
> Subject: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial
> index correctly?
>
> Hi,
>
> OK, lets put it this way:
> Is it sure that Mapserver is firing the BBOX query so that GDAL/OGR
> understands to follow the path that is implemented in
> http://trac.osgeo.org/gdal/changeset/23008
> instead of making an inefficient MBRIntersects()  query or some other slow
> query?
>
> I do not believe that a user like me has a possibility to check what really
> happens with Spatialite like I can do with PostGIS and Oracle because
> Spatialite does not collect a log file.
>
> -Jukka Rahkonen-
>
> Lime, Steve D (DNR)  wrote:
> There is no native support for Spatialite in MapServer, it's all through
> GDAL/OGR.
>
> Steve
> ________________________________
> From: mapserver-users-bounces <at> lists.osgeo.org
> [mapserver-users-bounces <at> lists.osgeo.org] on behalf of Rahkonen Jukka
> [Jukka.Rahkonen <at> mmmtike.fi]
> Sent: Friday, February 10, 2012 9:12 AM
> To: 'mapserver-users <at> lists.osgeo.org'
> Subject: [mapserver-users] Does Mapserver utilise Spatialite spatial index
> correctly?
> Hi,
>
> GDAL was made to utilise Spatialite spatial index effectively if it exists
> with ticket
> http://trac.osgeo.org/gdal/ticket/4212
> After this change ogr2ogr with -spat bounding box query is much faster.
> However, when testing MS4W 3.0.4beta1 which comes with GDAL 1.9, the
> rendering speed of Spatialite data with Mapserver is pretty slow. It is
> evenly slow when zoomed out and zoomed in which makes me believe that the
> spatial index is perhaps not used.
>
> Could it be that Mapserver does not utilise the improved method that was
> implemented for GDAL 1.9 when it is doing spatial queries from Spatialite?
>
> -Jukka Rahkonen-
>

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Even Rouault | 11 Feb 12:53

Re: Does Mapserver utilise Spatialite spatial index correctly?

Le samedi 11 février 2012 11:42:00, Rahkonen Jukka a écrit :
> Hi,
> 
> Perhaps it is not the spatial index at all, or it is not the most important
> part? It looks like OGR is using Spatialite through a connection pool and
> creating a new connection and pool is pretty heavy.  A first aid with a
> map with many layers is to use PROCESSING "CLOSE_CONNECTION=DEFER" even
> when running Mapserver as cgi.  It can save a couple of seconds per layer
> which makes a very big difference with the OSM default WMS group (from 40
> sec to 10 sec) . However, "CLOSE_CONNECTION=DEFER" cannot help with the
> pretty slow initial time but it would need some other kind of
> optimisation.

Jukka,

I'm currently analyzing your test case. Currently, I'm just using the mapserv 
executable from command line and after several consecutive runs, it stabilizes 
around 1.7 second to run

REQUEST_METHOD=GET

QUERY_STRING="map=/ms4w/osm_maps/osm_wms.map&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=663&HEIGHT=530&LAYERS=roadsclose_01&TRANSPARENT=TRUE&FORMAT=image%2Fpng&BBOX=1496457.8169701756,6889765.873308353,1497120.611899381,6890295.70937544&SRS=EPSG:3857&STYLES=" 
mapserv > /dev/null

Not as bad as what you are seing, but I believe it could be made faster. For 
the record my machine is a Core i5 750 with 4GB RAM, Ubuntu 10.04 64bit.

I've found 2 main areas that are time inefficient :

1) The opening of the DB needs some time to enumerate the layers.

2) The spatial index is not taken into account with your mapfiles. This is due 
to using stuff like "DATA "select geometry, osm_id ,highway,ref, name, tunnel 
from osm_line where highway is not null order by z_order"" that causes OGR to 
return a 'select layer' and not a table layer. Table layer currently benefit 
from spatial index when SetSpatialFilter() is called on them, but select 
layers do not. So you end up enumerating all features returned by the SQL 
request in the DATA.

For 1), I'm looking if it wouldn't be possible for the OGR SQLite driver to 
defer that enumeration
For 2), I'm looking if it wouldn't be possible for the OGR SQLite driver to 
modify the provided SQL request to insert in it the spatial filter, at least in 
simple cases (no join, no union).

Even
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Even Rouault | 11 Feb 16:03

Re: Does Mapserver utilise Spatialite spatial index correctly?

Le samedi 11 février 2012 12:53:08, Even Rouault a écrit :
> Le samedi 11 février 2012 11:42:00, Rahkonen Jukka a écrit :
> > Hi,
> > 
> > Perhaps it is not the spatial index at all, or it is not the most
> > important part? It looks like OGR is using Spatialite through a
> > connection pool and creating a new connection and pool is pretty heavy. 
> > A first aid with a map with many layers is to use PROCESSING
> > "CLOSE_CONNECTION=DEFER" even when running Mapserver as cgi.  It can
> > save a couple of seconds per layer which makes a very big difference
> > with the OSM default WMS group (from 40 sec to 10 sec) . However,
> > "CLOSE_CONNECTION=DEFER" cannot help with the pretty slow initial time
> > but it would need some other kind of
> > optimisation.
> 
> Jukka,
> 
> I'm currently analyzing your test case. Currently, I'm just using the
> mapserv executable from command line and after several consecutive runs,
> it stabilizes around 1.7 second to run
> 
> REQUEST_METHOD=GET
> QUERY_STRING="map=/ms4w/osm_maps/osm_wms.map&REQUEST=GetMap&SERVICE=WMS&VER
> SION=1.1.1&WIDTH=663&HEIGHT=530&LAYERS=roadsclose_01&TRANSPARENT=TRUE&FORMA
> T=image%2Fpng&BBOX=1496457.8169701756,6889765.873308353,1497120.611899381,6
> 890295.70937544&SRS=EPSG:3857&STYLES=" mapserv > /dev/null
> 
> Not as bad as what you are seing, but I believe it could be made faster.
> For the record my machine is a Core i5 750 with 4GB RAM, Ubuntu 10.04
> 64bit.
> 
> I've found 2 main areas that are time inefficient :
> 
> 1) The opening of the DB needs some time to enumerate the layers.
> 
> 2) The spatial index is not taken into account with your mapfiles. This is
> due to using stuff like "DATA "select geometry, osm_id ,highway,ref, name,
> tunnel from osm_line where highway is not null order by z_order"" that
> causes OGR to return a 'select layer' and not a table layer. Table layer
> currently benefit from spatial index when SetSpatialFilter() is called on
> them, but select layers do not. So you end up enumerating all features
> returned by the SQL request in the DATA.
> 
> For 1), I'm looking if it wouldn't be possible for the OGR SQLite driver to
> defer that enumeration
> For 2), I'm looking if it wouldn't be possible for the OGR SQLite driver to
> modify the provided SQL request to insert in it the spatial filter, at
> least in simple cases (no join, no union).

I've commited improvements in GDAL trunk for both points ( 
http://trac.osgeo.org/gdal/changeset/23944 and 
http://trac.osgeo.org/gdal/changeset/23945 ) that make the above request go 
from 1.7 sec to 0.54 sec . I don't think there's any more significant speed 
gain to expect now (at least on OGR side).

> 
> Even
> _______________________________________________
> mapserver-users mailing list
> mapserver-users <at> lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Even Rouault | 11 Feb 17:00

Re: Does Mapserver utilise Spatialite spatial index correctly?

> 
> I've commited improvements in GDAL trunk for both points (
> http://trac.osgeo.org/gdal/changeset/23944 and
> http://trac.osgeo.org/gdal/changeset/23945 ) that make the above request go
> from 1.7 sec to 0.54 sec . I don't think there's any more significant speed
> gain to expect now (at least on OGR side).

Actually, I found a new improvement (committed in  
http://trac.osgeo.org/gdal/changeset/23946) that make the query time go down 
to 0.07 sec (*) ! There was a slowness when opening the layer due to the 
presence of an ORDER BY clause in the DATA string, that was evaluated before 
setting the spatial filter.

(*) For comparison, I translated your database to Postgis, and set-up the 
connection mapfile to use that Postgis database (still through OGR, not the 
MapServer Postgis backend). The same request with OGR PG is run in 0.18 sec.

> 
> > Even
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users <at> lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users <at> lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Rahkonen Jukka | 11 Feb 22:43
Picon

Re: Does Mapserver utilise Spatialite spatial index correctly?

 Even Rouault wrote:

>
>> I've commited improvements in GDAL trunk for both points (
>> http://trac.osgeo.org/gdal/changeset/23944 and
>> http://trac.osgeo.org/gdal/changeset/23945 ) that make the above request go
>> from 1.7 sec to 0.54 sec . I don't think there's any more significant speed
>> gain to expect now (at least on OGR side).

> Actually, I found a new improvement (committed in
> http://trac.osgeo.org/gdal/changeset/23946) that make the query time go down
> to 0.07 sec (*) ! There was a slowness when opening the layer due to the
> presence of an ORDER BY clause in the DATA string, that was evaluated before
> setting the spatial filter.

> (*) For comparison, I translated your database to Postgis, and set-up the
> connection mapfile to use that Postgis database (still through OGR, not the
> MapServer Postgis backend). The same request with OGR PG is run in 0.18 sec.

Awesome!  About 25 times faster in the evening than it was in the morning. My opinion is that because
Spatialite seems to be, at least in this case, more that two times faster backend for Mapserver than
PostGIS it should lead to some intensive and controlled testing now.

Regards,

-Jukka Rahkonen-_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Fawcett, David (MPCA | 13 Feb 16:56
Picon
Picon
Favicon

RE: Does Mapserver utilise Spatialite spatial index correctly?

A pretty good story to tell when talking about the advantages of OpenSource software...

-----Original Message-----
From: mapserver-users-bounces <at> lists.osgeo.org
[mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Rahkonen Jukka
Sent: Saturday, February 11, 2012 3:43 PM
To: Even Rouault; mapserver-users <at> lists.osgeo.org
Subject: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

 Even Rouault wrote:

>
>> I've commited improvements in GDAL trunk for both points (

Awesome!  About 25 times faster in the evening than it was in the morning. My opinion is that because
Spatialite seems to be, at least in this case, more that two times faster backend for Mapserver than
PostGIS it should lead to some intensive and controlled testing now.

Regards,

-Jukka Rahkonen-_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Rahkonen Jukka | 14 Feb 09:24
Picon

Re: Does Mapserver utilise Spatialite spatial index correctly?


Rahkonen Jukka wrote:
> 
>  Even Rouault wrote:
> 
> >
> >> I've commited improvements in GDAL trunk for both points (
> >> http://trac.osgeo.org/gdal/changeset/23944 and
> >> http://trac.osgeo.org/gdal/changeset/23945 ) that make the 
> above request go
> >> from 1.7 sec to 0.54 sec . I don't think there's any more 
> significant speed
> >> gain to expect now (at least on OGR side).
> 
> > Actually, I found a new improvement (committed in
> > http://trac.osgeo.org/gdal/changeset/23946) that make the 
> query time go down
> > to 0.07 sec (*) ! There was a slowness when opening the 
> layer due to the
> > presence of an ORDER BY clause in the DATA string, that was 
> evaluated before
> > setting the spatial filter.
> 
> > (*) For comparison, I translated your database to Postgis, 
> and set-up the
> > connection mapfile to use that Postgis database (still 
> through OGR, not the
> > MapServer Postgis backend). The same request with OGR PG is 
> run in 0.18 sec.
> 
> Awesome!  About 25 times faster in the evening than it was in 
> the morning. My opinion is that because Spatialite seems to 
> be, at least in this case, more that two times faster backend 
> for Mapserver than PostGIS it should lead to some intensive 
> and controlled testing now.

I updated the cgi-bin directory of my MS4W 3.0.4beta1 with the mapserv.exe and dll files taken from the
brand new binaries from http://www.gisinternals.com/sdk/ (contains Mapserver and GDAL revisions
r13144, r23972, respectively).

As a result Mapserver is really serving me 10, or 25 or even 40 times faster than it did before the update
measured as WMS throughput (images/minute). The times include rendering times and all the lags in the
system so the difference tells exactly how the end user feels it. Greatest enhancement is with close zooms
because then the apatial index bites hardest. And at least with my computer Spatialite backend is clearly
faster than PostGIS with the same data and it may be even faster than shapefiles but it is too early to say
that really. But this is absolutely something worth more testing.

My test database is moderately sized and contains 100000 points, 90000 lines and 149000 polygons from
OpenStreetMap data. I will myself do next trials with ten times bigger Spatialite database with
something like million points, lines, and polygons. We do not have much bigger tables in our production.
However, I do not believe we are changing from Oracle to SQLite/Spatialite very rapidly in our core
business :)

-Jukka Rahkonen-

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Fawcett, David (MPCA | 14 Feb 15:01
Picon
Picon
Favicon

RE: Does Mapserver utilise Spatialite spatial index correctly?

Great work Jukka (and Even).  Thanks for pursuing this!!

David.

-----Original Message-----
From: mapserver-users-bounces <at> lists.osgeo.org
[mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Rahkonen Jukka
Sent: Tuesday, February 14, 2012 2:24 AM
To: 'mapserver-users <at> lists.osgeo.org'
Subject: Re: [mapserver-users] Does Mapserver utilise Spatialite spatial index correctly?

 
Rahkonen Jukka wrote:
> 
>  Even Rouault wrote:
> 
> >
> >> I've commited improvements in GDAL trunk for both points (
> >> http://trac.osgeo.org/gdal/changeset/23944 and
> >> http://trac.osgeo.org/gdal/changeset/23945 ) that make the 
> above request go
> >> from 1.7 sec to 0.54 sec . I don't think there's any more 
> significant speed
> >> gain to expect now (at least on OGR side).
> 
> > Actually, I found a new improvement (committed in
> > http://trac.osgeo.org/gdal/changeset/23946) that make the 
> query time go down
> > to 0.07 sec (*) ! There was a slowness when opening the 
> layer due to the
> > presence of an ORDER BY clause in the DATA string, that was 
> evaluated before
> > setting the spatial filter.
> 
> > (*) For comparison, I translated your database to Postgis, 
> and set-up the
> > connection mapfile to use that Postgis database (still 
> through OGR, not the
> > MapServer Postgis backend). The same request with OGR PG is 
> run in 0.18 sec.
> 
> Awesome!  About 25 times faster in the evening than it was in 
> the morning. My opinion is that because Spatialite seems to 
> be, at least in this case, more that two times faster backend 
> for Mapserver than PostGIS it should lead to some intensive 
> and controlled testing now.

I updated the cgi-bin directory of my MS4W 3.0.4beta1 with the mapserv.exe and dll files taken from the
brand new binaries from http://www.gisinternals.com/sdk/ (contains Mapserver and GDAL revisions
r13144, r23972, respectively).

As a result Mapserver is really serving me 10, or 25 or even 40 times faster than it did before the update
measured as WMS throughput (images/minute). The times include rendering times and all the lags in the
system so the difference tells exactly how the end user feels it. Greatest enhancement is with close zooms
because then the apatial index bites hardest. And at least with my computer Spatialite backend is clearly
faster than PostGIS with the same data and it may be even faster than shapefiles but it is too early to say
that really. But this is absolutely something worth more testing.

My test database is moderately sized and contains 100000 points, 90000 lines and 149000 polygons from
OpenStreetMap data. I will myself do next trials with ten times bigger Spatialite database with
something like million points, lines, and polygons. We do not have much bigger tables in our production.
However, I do not believe we are changing from Oracle to SQLite/Spatialite very rapidly in our core
business :)

-Jukka Rahkonen-

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Even Rouault | 14 Feb 19:40

Re: Does Mapserver utilise Spatialite spatial index correctly?

Le mardi 14 février 2012 09:24:15, Rahkonen Jukka a écrit :
> Rahkonen Jukka wrote:
> >  Even Rouault wrote:
> > >> I've commited improvements in GDAL trunk for both points (
> > >> http://trac.osgeo.org/gdal/changeset/23944 and
> > >> http://trac.osgeo.org/gdal/changeset/23945 ) that make the
> > 
> > above request go
> > 
> > >> from 1.7 sec to 0.54 sec . I don't think there's any more
> > 
> > significant speed
> > 
> > >> gain to expect now (at least on OGR side).
> > > 
> > > Actually, I found a new improvement (committed in
> > > http://trac.osgeo.org/gdal/changeset/23946) that make the
> > 
> > query time go down
> > 
> > > to 0.07 sec (*) ! There was a slowness when opening the
> > 
> > layer due to the
> > 
> > > presence of an ORDER BY clause in the DATA string, that was
> > 
> > evaluated before
> > 
> > > setting the spatial filter.
> > > 
> > > (*) For comparison, I translated your database to Postgis,
> > 
> > and set-up the
> > 
> > > connection mapfile to use that Postgis database (still
> > 
> > through OGR, not the
> > 
> > > MapServer Postgis backend). The same request with OGR PG is
> > 
> > run in 0.18 sec.
> > 
> > Awesome!  About 25 times faster in the evening than it was in
> > the morning. My opinion is that because Spatialite seems to
> > be, at least in this case, more that two times faster backend
> > for Mapserver than PostGIS it should lead to some intensive
> > and controlled testing now.
> 
> I updated the cgi-bin directory of my MS4W 3.0.4beta1 with the mapserv.exe
> and dll files taken from the brand new binaries from
> http://www.gisinternals.com/sdk/ (contains Mapserver and GDAL revisions
> r13144, r23972, respectively).
> 
> As a result Mapserver is really serving me 10, or 25 or even 40 times
> faster than it did before the update measured as WMS throughput
> (images/minute). The times include rendering times and all the lags in the
> system so the difference tells exactly how the end user feels it. Greatest
> enhancement is with close zooms because then the apatial index bites
> hardest. And at least with my computer Spatialite backend is clearly
> faster than PostGIS with the same data and it may be even faster than
> shapefiles but it is too early to say that really. But this is absolutely
> something worth more testing.

I tested a bit with shapefiles with your Berlin OSM database. Even after adding 
spatial index (.qix) and attribute index (.idm & .idn) on fields in where 
clauses, it is a bit slower than spatialite. If you remove all columns from 
the DBF that are not necessary for the rendering, it improves things a bit 
again. You can also try the new special SQL command "RESIZE table_name" for 
shapefiles I've committed yesterday (see http://gdal.org/ogr/drv_shapefile.html 
) to adjust columns to their minimum needed size.

> 
> My test database is moderately sized and contains 100000 points, 90000
> lines and 149000 polygons from OpenStreetMap data. I will myself do next
> trials with ten times bigger Spatialite database with something like
> million points, lines, and polygons. We do not have much bigger tables in
> our production. However, I do not believe we are changing from Oracle to
> SQLite/Spatialite very rapidly in our core business :)
> 
> -Jukka Rahkonen-
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users <at> lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Rahkonen Jukka | 15 Feb 13:04
Picon

Re: Does Mapserver utilise Spatialite spatial index correctly?

Even Rouault wrote:
> 
> Le mardi 14 février 2012 09:24:15, Rahkonen Jukka a écrit :
> > Rahkonen Jukka wrote:
> > >  Even Rouault wrote:
> > > >> I've commited improvements in GDAL trunk for both points (
> > > >> http://trac.osgeo.org/gdal/changeset/23944 and
> > > >> http://trac.osgeo.org/gdal/changeset/23945 ) that make the
> > > 
> > > above request go
> > > 
> > > >> from 1.7 sec to 0.54 sec . I don't think there's any more
> > > 
> > > significant speed
> > > 
> > > >> gain to expect now (at least on OGR side).
> > > > 
> > > > Actually, I found a new improvement (committed in
> > > > http://trac.osgeo.org/gdal/changeset/23946) that make the
> > > 
> > > query time go down
> > > 
> > > > to 0.07 sec (*) ! There was a slowness when opening the
> > > 
> > > layer due to the
> > > 
> > > > presence of an ORDER BY clause in the DATA string, that was
> > > 
> > > evaluated before
> > > 
> > > > setting the spatial filter.
> > > > 
> > > > (*) For comparison, I translated your database to Postgis,
> > > 
> > > and set-up the
> > > 
> > > > connection mapfile to use that Postgis database (still
> > > 
> > > through OGR, not the
> > > 
> > > > MapServer Postgis backend). The same request with OGR PG is
> > > 
> > > run in 0.18 sec.
> > > 
> > > Awesome!  About 25 times faster in the evening than it was in
> > > the morning. My opinion is that because Spatialite seems to
> > > be, at least in this case, more that two times faster backend
> > > for Mapserver than PostGIS it should lead to some intensive
> > > and controlled testing now.
> > 
> > I updated the cgi-bin directory of my MS4W 3.0.4beta1 with 
> the mapserv.exe
> > and dll files taken from the brand new binaries from
> > http://www.gisinternals.com/sdk/ (contains Mapserver and 
> GDAL revisions
> > r13144, r23972, respectively).
> > 
> > As a result Mapserver is really serving me 10, or 25 or 
> even 40 times
> > faster than it did before the update measured as WMS throughput
> > (images/minute). The times include rendering times and all 
> the lags in the
> > system so the difference tells exactly how the end user 
> feels it. Greatest
> > enhancement is with close zooms because then the apatial index bites
> > hardest. And at least with my computer Spatialite backend is clearly
> > faster than PostGIS with the same data and it may be even 
> faster than
> > shapefiles but it is too early to say that really. But this 
> is absolutely
> > something worth more testing.
> 
> I tested a bit with shapefiles with your Berlin OSM database. 
> Even after adding 
> spatial index (.qix) and attribute index (.idm & .idn) on 
> fields in where 
> clauses, it is a bit slower than spatialite. If you remove 
> all columns from 
> the DBF that are not necessary for the rendering, it improves 
> things a bit 
> again. You can also try the new special SQL command "RESIZE 
> table_name" for 
> shapefiles I've committed yesterday (see 
> http://gdal.org/ogr/drv_shapefile.html 
> ) to adjust columns to their minimum needed size.

I prepared a new Spatialite database from the OSM data of Finland. It contains 230000 points, 480000 lines
and 440000 polygons and takes 700 MB on a disk. I made indexes for everything that is used in the WHERE
selections and the result is just wonderful.  If there is just few features to render the msDrawMap() takes
just 0.01 - 0.10 seconds per layer (1000x800 sized output). And my computer is eight year old Windows WP
with IDE disks and 1 GB of memory. Rendering lots of features takes naturally longer time but I do believe
that technically GDAL/OGR/Mapserver side is in the order now and there is not much room for further
improvements there.

Best way for improving the speed of the service from this point is to generalize the data for rendering at
small scales. Spatialite has Simplify() and SimplifyPreserveTopolygy() functions so it will be very
easy to create simplified versions of the data into the same database. Features which are unreasonably
small for rendering at the target scale can be sorted out at the same. I can imagine that one day some clever
individual will write a tool that automatically runs SQL script which creates a set of new tables with
simplified geometries into Spatialite and at the same time writes a corresponding mapfile which
collects those tables as scale dependent layers under one Mapserver layer group.  

By the way, it would be very nice if the full stop at TopologyExceptions could be avoided. My Spatialite
databases are created by ogr2ogr and self-intersections did not stop OGR then so perhaps it can be made to
tolerate them also in this case. Now I fixed this problem in a crude way by running "DELETE from osm_polygon
where ST_IsValid(GEOMETRY)<=0".

-Jukka Rahkonen-

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Stephen Woodbridge | 15 Feb 14:54
Favicon

Re: Does Mapserver utilise Spatialite spatial index correctly?

On 2/15/2012 7:04 AM, Rahkonen Jukka wrote:
> Even Rouault wrote:
>>
>> Le mardi 14 février 2012 09:24:15, Rahkonen Jukka a écrit :
>>> Rahkonen Jukka wrote:
>>>> Even Rouault wrote:
>>>>>> I've commited improvements in GDAL trunk for both points (
>>>>>> http://trac.osgeo.org/gdal/changeset/23944 and
>>>>>> http://trac.osgeo.org/gdal/changeset/23945 ) that make the
>>>>
>>>> above request go
>>>>
>>>>>> from 1.7 sec to 0.54 sec . I don't think there's any more
>>>>
>>>> significant speed
>>>>
>>>>>> gain to expect now (at least on OGR side).
>>>>>
>>>>> Actually, I found a new improvement (committed in
>>>>> http://trac.osgeo.org/gdal/changeset/23946) that make the
>>>>
>>>> query time go down
>>>>
>>>>> to 0.07 sec (*) ! There was a slowness when opening the
>>>>
>>>> layer due to the
>>>>
>>>>> presence of an ORDER BY clause in the DATA string, that was
>>>>
>>>> evaluated before
>>>>
>>>>> setting the spatial filter.
>>>>>
>>>>> (*) For comparison, I translated your database to Postgis,
>>>>
>>>> and set-up the
>>>>
>>>>> connection mapfile to use that Postgis database (still
>>>>
>>>> through OGR, not the
>>>>
>>>>> MapServer Postgis backend). The same request with OGR PG is
>>>>
>>>> run in 0.18 sec.
>>>>
>>>> Awesome!  About 25 times faster in the evening than it was in
>>>> the morning. My opinion is that because Spatialite seems to be,
>>>> at least in this case, more that two times faster backend for
>>>> Mapserver than PostGIS it should lead to some intensive and
>>>> controlled testing now.
>>>
>>> I updated the cgi-bin directory of my MS4W 3.0.4beta1 with
>> the mapserv.exe
>>> and dll files taken from the brand new binaries from
>>> http://www.gisinternals.com/sdk/ (contains Mapserver and
>> GDAL revisions
>>> r13144, r23972, respectively).
>>>
>>> As a result Mapserver is really serving me 10, or 25 or
>> even 40 times
>>> faster than it did before the update measured as WMS throughput
>>> (images/minute). The times include rendering times and all
>> the lags in the
>>> system so the difference tells exactly how the end user
>> feels it. Greatest
>>> enhancement is with close zooms because then the apatial index
>>> bites hardest. And at least with my computer Spatialite backend
>>> is clearly faster than PostGIS with the same data and it may be
>>> even
>> faster than
>>> shapefiles but it is too early to say that really. But this
>> is absolutely
>>> something worth more testing.
>>
>> I tested a bit with shapefiles with your Berlin OSM database. Even
>> after adding spatial index (.qix) and attribute index (.idm&  .idn)
>> on fields in where clauses, it is a bit slower than spatialite. If
>> you remove all columns from the DBF that are not necessary for the
>> rendering, it improves things a bit again. You can also try the new
>> special SQL command "RESIZE table_name" for shapefiles I've
>> committed yesterday (see http://gdal.org/ogr/drv_shapefile.html )
>> to adjust columns to their minimum needed size.
>
> I prepared a new Spatialite database from the OSM data of Finland. It
> contains 230000 points, 480000 lines and 440000 polygons and takes
> 700 MB on a disk. I made indexes for everything that is used in the
> WHERE selections and the result is just wonderful.  If there is just
> few features to render the msDrawMap() takes just 0.01 - 0.10 seconds
> per layer (1000x800 sized output). And my computer is eight year old
> Windows WP with IDE disks and 1 GB of memory. Rendering lots of
> features takes naturally longer time but I do believe that
> technically GDAL/OGR/Mapserver side is in the order now and there is
> not much room for further improvements there.
>
> Best way for improving the speed of the service from this point is to
> generalize the data for rendering at small scales. Spatialite has
> Simplify() and SimplifyPreserveTopolygy() functions so it will be
> very easy to create simplified versions of the data into the same
> database. Features which are unreasonably small for rendering at the
> target scale can be sorted out at the same. I can imagine that one
> day some clever individual will write a tool that automatically runs
> SQL script which creates a set of new tables with simplified
> geometries into Spatialite and at the same time writes a
> corresponding mapfile which collects those tables as scale dependent
> layers under one Mapserver layer group.
>
> By the way, it would be very nice if the full stop at
> TopologyExceptions could be avoided. My Spatialite databases are
> created by ogr2ogr and self-intersections did not stop OGR then so
> perhaps it can be made to tolerate them also in this case. Now I
> fixed this problem in a crude way by running "DELETE from osm_polygon
> where ST_IsValid(GEOMETRY)<=0".

There is a hack in postGIS that might work here:

update osm_polygon set GEOMETRY=ST_Buffer(GEOMERTY, 0.0) where 
ST_IsValid(GEOMETRY)<=0;

This will fix some if not all the polygons. Then run your delete 
afterwards to clean out the rest. This may/may not work with SpatiaLite.

-Steve
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Even Rouault | 11 Feb 22:44

Re: Does Mapserver utilise Spatialite spatial index correctly?

Jukka,

I've continued playing with your OSM data.

I've got extra performance by adding attribute indexes, so that every field you 
use in a WHERE clause is indexed. For example for the roadsclose, railways and 
landuse layers, you could create the following indexes:

CREATE INDEX idx_osm_line_railway ON osm_line(railway)
CREATE INDEX idx_osm_line_highway ON osm_line(highway)
CREATE INDEX idx_osm_polygon_landuse ON osm_polygon(landuse)
CREATE INDEX idx_osm_polygon_leisure ON osm_polygon(leisure)
CREATE INDEX idx_osm_polygon_amenity ON osm_polygon(amenity)
CREATE INDEX idx_osm_polygon_aeroway ON osm_polygon(aeroway)
CREATE INDEX idx_osm_polygon_natural ON osm_polygon(natural)
CREATE INDEX idx_osm_polygon_highway ON osm_polygon(highway)
CREATE INDEX idx_osm_polygon_waterway ON osm_polygon(waterway)

Best regards,

Even
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Jeff McKenna | 13 Feb 14:26
Favicon

Re: Does Mapserver utilise Spatialite spatial index correctly?

Quite an interesting discussion!  Thanks guys.

-jeff

On 12-02-11 5:44 PM, Even Rouault wrote:
> Jukka,
>
> I've continued playing with your OSM data.
>
> I've got extra performance by adding attribute indexes, so that every field you
> use in a WHERE clause is indexed. For example for the roadsclose, railways and
> landuse layers, you could create the following indexes:
>
> CREATE INDEX idx_osm_line_railway ON osm_line(railway)
> CREATE INDEX idx_osm_line_highway ON osm_line(highway)
> CREATE INDEX idx_osm_polygon_landuse ON osm_polygon(landuse)
> CREATE INDEX idx_osm_polygon_leisure ON osm_polygon(leisure)
> CREATE INDEX idx_osm_polygon_amenity ON osm_polygon(amenity)
> CREATE INDEX idx_osm_polygon_aeroway ON osm_polygon(aeroway)
> CREATE INDEX idx_osm_polygon_natural ON osm_polygon(natural)
> CREATE INDEX idx_osm_polygon_highway ON osm_polygon(highway)
> CREATE INDEX idx_osm_polygon_waterway ON osm_polygon(waterway)
>

--

-- 
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Jan Hartmann | 14 Feb 18:03
Picon
Picon
Favicon

Constraining label position

Hi,

The development version of Openlayers has a new facility: smooth tile transition. When panning, the old image remains visible for 2.5 seconds under the new one, so as to make the panning process smoother. This works fine for static maps, but gives undesired effects with MapServer labels. Those are computed anew for every request, so e.g. labels for items at the corner of the map get a different position, to keep them inside the displayed map. This results in old and new labels being displayed next to one another for some time.

Is there an option in MapServer to constrain the labels to always have the same position respective to the geometry they are labeling?

Jan
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Stephen Woodbridge | 14 Feb 18:17
Favicon

Re: Constraining label position

On 2/14/2012 12:03 PM, Jan Hartmann wrote:
> Hi,
>
> The development version of Openlayers has a new facility: smooth tile
> transition. When panning, the old image remains visible for 2.5 seconds
> under the new one, so as to make the panning process smoother. This
> works fine for static maps, but gives undesired effects with MapServer
> labels. Those are computed anew for every request, so e.g. labels for
> items at the corner of the map get a different position, to keep them
> inside the displayed map. This results in old and new labels being
> displayed next to one another for some time.
>
> Is there an option in MapServer to constrain the labels to always have
> the same position respective to the geometry they are labeling?

google: mapserver geomtransform

this will let you fix the label point to the centroid of the object or 
some other positions.

The issue is that the label point is generally calculated based on the 
geometry of the object as clipped to the view port. So the geometry 
changes based on the view clipping and this causes the label point to 
also change. the geomtransform works on the original data and so the 
label point becomes fixed.

There is also a lot of label enhancements being added to trunk for the 
next release. You might want to look at rfc 77 [1] in additions to rfc 
72 [2].

[1] http://mapserver.org/development/rfc/ms-rfc-77.html
[2] http://mapserver.org/development/rfc/ms-rfc-72.html

-Steve W
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Jan Hartmann | 20 Feb 15:27
Picon
Picon
Favicon

Re: Constraining label position



On 02/14/2012 06:17 PM, Stephen Woodbridge wrote:
google: mapserver geomtransform

this will let you fix the label point to the centroid of the object or some other positions.

The issue is that the label point is generally calculated based on the geometry of the object as clipped to the view port. So the geometry changes based on the view clipping and this causes the label point to also change. the geomtransform works on the original data and so the label point becomes fixed.


No I can't get this to work, perhaps I don't understand the syntax of geomtransform. Can you give me an example of fixing a label to the center point of a rectangle, without shifting it when the rectangle crosses the viewport? My mapfile looks:

connectiontype postgis
connection ""
data the_rect from bnds
labelitem rect_id
style
  color 0 0 0
end
label
  color 0 0 255
end

I put a few geotransforms within the label and within the style objects, but the label always shifts near the margin of the viewport.

Thanks,

Jan
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
thomas bonfort | 20 Feb 15:30
Picon
Gravatar

Re: Constraining label position

PROCESSING "LABEL_NO_CLIP=yes"

--
thomas

On Mon, Feb 20, 2012 at 15:27, Jan Hartmann <j.l.h.hartmann <at> uva.nl> wrote:
>
>
> On 02/14/2012 06:17 PM, Stephen Woodbridge wrote:
>
> google: mapserver geomtransform
>
> this will let you fix the label point to the centroid of the object or some
> other positions.
>
> The issue is that the label point is generally calculated based on the
> geometry of the object as clipped to the view port. So the geometry changes
> based on the view clipping and this causes the label point to also change.
> the geomtransform works on the original data and so the label point becomes
> fixed.
>
>
> No I can't get this to work, perhaps I don't understand the syntax of
> geomtransform. Can you give me an example of fixing a label to the center
> point of a rectangle, without shifting it when the rectangle crosses the
> viewport? My mapfile looks:
>
> connectiontype postgis
> connection ""
> data the_rect from bnds
> labelitem rect_id
> style
>   color 0 0 0
> end
> label
>   color 0 0 255
> end
>
> I put a few geotransforms within the label and within the style objects, but
> the label always shifts near the margin of the viewport.
>
> Thanks,
>
> Jan
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users <at> lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Jan Hartmann | 20 Feb 15:41
Picon
Picon
Favicon

Re: Constraining label position

That's it, thanks Thomas. It's a problem with the development version of OpenLayers, where during a map refresh the old version remains visible for some time next to the updated one, in order to get a smooth transition. I find intelligent labelpositioning more important than smooth transitions, so I'll suggest to them an option to disable the smoothing effect.

Jan

On 02/20/2012 03:30 PM, thomas bonfort wrote:
PROCESSING "LABEL_NO_CLIP=yes" -- thomas On Mon, Feb 20, 2012 at 15:27, Jan Hartmann <j.l.h.hartmann <at> uva.nl> wrote:
On 02/14/2012 06:17 PM, Stephen Woodbridge wrote: google: mapserver geomtransform this will let you fix the label point to the centroid of the object or some other positions. The issue is that the label point is generally calculated based on the geometry of the object as clipped to the view port. So the geometry changes based on the view clipping and this causes the label point to also change. the geomtransform works on the original data and so the label point becomes fixed. No I can't get this to work, perhaps I don't understand the syntax of geomtransform. Can you give me an example of fixing a label to the center point of a rectangle, without shifting it when the rectangle crosses the viewport? My mapfile looks: connectiontype postgis connection "" data the_rect from bnds labelitem rect_id style   color 0 0 0 end label   color 0 0 255 end I put a few geotransforms within the label and within the style objects, but the label always shifts near the margin of the viewport. Thanks, Jan _______________________________________________ mapserver-users mailing list mapserver-users <at> lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Jan Hartmann | 21 Feb 17:23
Picon
Picon
Favicon

Aligning labels within a polygon

Hi,

I'm inputting lots of street address points in PostGIS, and try to generate labels for the streets. The convex hull of the points of a street approximate the course of the street, and I would like to position the streetname in the middle of the convex hull polygon, aligned to its dominant angle (the polygons are generally quite narrow). Is there a way of doing this with MapServer? Perhaps by thinning out the polygon to a line, for then I can use "angle follow".

Jan
_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Fawcett, David (MPCA | 21 Feb 17:27
Picon
Picon
Favicon

RE: Aligning labels within a polygon

If you are storing the data in PostGIS, you could possibly take advantage of ST_Azimuth().  http://www.postgis.org/docs/ST_Azimuth.html

 

It takes two point objects as the args, but you could potentially use the start and end points of your linestring.

 

David.

 

From: mapserver-users-bounces <at> lists.osgeo.org [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Jan Hartmann
Sent: Tuesday, February 21, 2012 10:23 AM
To: mapserver-users <at> lists.osgeo.org
Subject: [mapserver-users] Aligning labels within a polygon

 

Hi,

I'm inputting lots of street address points in PostGIS, and try to generate labels for the streets. The convex hull of the points of a street approximate the course of the street, and I would like to position the streetname in the middle of the convex hull polygon, aligned to its dominant angle (the polygons are generally quite narrow). Is there a way of doing this with MapServer? Perhaps by thinning out the polygon to a line, for then I can use "angle follow".

Jan

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Jan Hartmann | 21 Feb 18:17
Picon
Picon
Favicon

Re: Aligning labels within a polygon

Going a step further:

st_longestline(st_collect(the_geom),st_collect(the_geom))

gives the longest line segment that can be drawn within the cluster of street address points. Works for non-curved streets. I'm still looking for a more intelligent way to thin out a polygon to a (multi)line.

Jan

On 02/21/2012 05:27 PM, Fawcett, David (MPCA) wrote:

If you are storing the data in PostGIS, you could possibly take advantage of ST_Azimuth().  http://www.postgis.org/docs/ST_Azimuth.html

 

It takes two point objects as the args, but you could potentially use the start and end points of your linestring.

 

David.

 

From: mapserver-users-bounces <at> lists.osgeo.org [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Jan Hartmann
Sent: Tuesday, February 21, 2012 10:23 AM
To: mapserver-users <at> lists.osgeo.org
Subject: [mapserver-users] Aligning labels within a polygon

 

Hi,

I'm inputting lots of street address points in PostGIS, and try to generate labels for the streets. The convex hull of the points of a street approximate the course of the street, and I would like to position the streetname in the middle of the convex hull polygon, aligned to its dominant angle (the polygons are generally quite narrow). Is there a way of doing this with MapServer? Perhaps by thinning out the polygon to a line, for then I can use "angle follow".

Jan

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Fawcett, David (MPCA | 21 Feb 20:19
Picon
Picon
Favicon

RE: Aligning labels within a polygon

Several years ago, I wrote some Python code to roughly georeference air photos.  As part of that, I needed to come up with the best approximation of the heading of the airplane. 

 

What worked pretty well was to do a really simple line fitting based on the points.  My samples were points from an airplane that was attempting to fly in a straight line, with vertices generated by a camera taking pictures at regular intervals, so that helped. 

 

I simply split the vertices of the line into three groups by dividing the total number of points by 3.  I averaged the x and y values in each group and then created a line from the average coord from group1 to the average coord from group3. 

 

Street data will likely be more variable (curved), but you may want to explore something like this.  Of course, you would likely want to calculate these label angles using pre-processing to speed up rendering time.

 

David.

 

 

 

From: mapserver-users-bounces <at> lists.osgeo.org [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Jan Hartmann
Sent: Tuesday, February 21, 2012 11:18 AM
To: Fawcett, David (MPCA)
Cc: mapserver-users <at> lists.osgeo.org
Subject: Re: [mapserver-users] Aligning labels within a polygon

 

Going a step further:

st_longestline(st_collect(the_geom),st_collect(the_geom))

gives the longest line segment that can be drawn within the cluster of street address points. Works for non-curved streets. I'm still looking for a more intelligent way to thin out a polygon to a (multi)line.

Jan

On 02/21/2012 05:27 PM, Fawcett, David (MPCA) wrote:

If you are storing the data in PostGIS, you could possibly take advantage of ST_Azimuth().  http://www.postgis.org/docs/ST_Azimuth.html

 

It takes two point objects as the args, but you could potentially use the start and end points of your linestring.

 

David.

 

From: mapserver-users-bounces <at> lists.osgeo.org [mailto:mapserver-users-bounces <at> lists.osgeo.org] On Behalf Of Jan Hartmann
Sent: Tuesday, February 21, 2012 10:23 AM
To: mapserver-users <at> lists.osgeo.org
Subject: [mapserver-users] Aligning labels within a polygon

 

Hi,

I'm inputting lots of street address points in PostGIS, and try to generate labels for the streets. The convex hull of the points of a street approximate the course of the street, and I would like to position the streetname in the middle of the convex hull polygon, aligned to its dominant angle (the polygons are generally quite narrow). Is there a way of doing this with MapServer? Perhaps by thinning out the polygon to a line, for then I can use "angle follow".

Jan

_______________________________________________
mapserver-users mailing list
mapserver-users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Gmane