Re: [mapserver-users] Calculate length!
Hi, The GDAL version is not what is essential but the version of the dependent Spatialite library. GDAL must be compiled with such Spatialite version that has support for ST_Length. The error means either that Spatialite is missing totally or that it is of too old version and in this case it is obvioustly the latter. However, there may be a simple solution. ST-functions are new synonyms but your older Spatialite version may support the native name that Spatialite has used for the function https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html. Try if SELECT glength(geometry) happens to work. Otherwise you must try to find a GDAL version that is compiled with more fresh Spatialite. -Jukka Rahkonen- Schylberg Lars wrote: I guess this must be a version problem. That same command runs fine on my osgeolive8 machine. ogrinfo --version GDAL 1.10.1, released 2013/08/26 /Lars From: mapserver-users-boun...@lists.osgeo.org<mailto:mapserver-users-boun...@lists.osgeo.org> [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of alok mathur Sent: den 16 mars 2015 09:54 To: Rahkonen Jukka (MML); mapserver-users@lists.osgeo.org<mailto:mapserver-users@lists.osgeo.org> Subject: Re: [mapserver-users] Calculate length! Hi Jukka, When i am trying to run the above ogr command as mentioned by you I am getting an error ogrinfo -dialect sqlite -sql "select st_length(geometry) from 'Fibertech solution'" doc_test.kml INFO: Open of `doc_test.kml' using driver `LIBKML' successful. ERROR 1: In ExecuteSQL(): sqlite3_prepare(select st_length(geometry) from 'Fibertech solution'): no such function: st_length Please let me know what the issue is. I have installed both libsqlite3 and libspatialite. Thanks! Alok ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
Lars, I have the latest OGR GDAL 1.11.2, released 2015/02/10 Thanks! Alok On Mon, Mar 16, 2015 at 5:39 PM, Schylberg Lars < lars.schylb...@saabgroup.com> wrote: > I guess this must be a version problem. That same command runs fine on > my osgeolive8 machine. > > > > ogrinfo --version > > GDAL 1.10.1, released 2013/08/26 > > > > /Lars > > > > > > *From:* mapserver-users-boun...@lists.osgeo.org [mailto: > mapserver-users-boun...@lists.osgeo.org] *On Behalf Of *alok mathur > *Sent:* den 16 mars 2015 09:54 > *To:* Rahkonen Jukka (MML); mapserver-users@lists.osgeo.org > *Subject:* Re: [mapserver-users] Calculate length! > > > > Hi Jukka, > > > > When i am trying to run the above ogr command as mentioned by you I am > getting an error > > > > ogrinfo -dialect sqlite -sql "select st_length(geometry) from 'Fibertech > solution'" doc_test.kml > > INFO: Open of `doc_test.kml' > > using driver `LIBKML' successful. > > ERROR 1: In ExecuteSQL(): sqlite3_prepare(select st_length(geometry) from > 'Fibertech solution'): > > no such function: st_length > > > > > > > > Please let me know what the issue is. I have installed both libsqlite3 and > libspatialite. > > > > Thanks! > > Alok > > > > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/mapserver-users > -- *Alok Mathur* | Software Engineer 2A | Ciena Mobile +91 9899413266 ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
I guess this must be a version problem. That same command runs fine on my osgeolive8 machine. ogrinfo --version GDAL 1.10.1, released 2013/08/26 /Lars From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of alok mathur Sent: den 16 mars 2015 09:54 To: Rahkonen Jukka (MML); mapserver-users@lists.osgeo.org Subject: Re: [mapserver-users] Calculate length! Hi Jukka, When i am trying to run the above ogr command as mentioned by you I am getting an error ogrinfo -dialect sqlite -sql "select st_length(geometry) from 'Fibertech solution'" doc_test.kml INFO: Open of `doc_test.kml' using driver `LIBKML' successful. ERROR 1: In ExecuteSQL(): sqlite3_prepare(select st_length(geometry) from 'Fibertech solution'): no such function: st_length Please let me know what the issue is. I have installed both libsqlite3 and libspatialite. Thanks! Alok ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
Hi Jukka, When i am trying to run the above ogr command as mentioned by you I am getting an error ogrinfo -dialect sqlite -sql "select st_length(geometry) from 'Fibertech solution'" doc_test.kml INFO: Open of `doc_test.kml' using driver `LIBKML' successful. ERROR 1: In ExecuteSQL(): sqlite3_prepare(select st_length(geometry) from 'Fibertech solution'): no such function: st_length Please let me know what the issue is. I have installed both libsqlite3 and libspatialite. Thanks! Alok On Fri, Mar 13, 2015 at 5:04 PM, Rahkonen Jukka (MML) < jukka.rahko...@maanmittauslaitos.fi> wrote: > Hi, > > > > You do not need anything else than GDAL which is compiled with libraries > libsqlite3 and libspatialite. > > If you have a suitable GDAL version you should be able to repeat this with > the attached small KML file. > > > > > > ogrinfo -dialect sqlite -sql "select st_length(geometry) from Layer0" > lines.kml > > INFO: Open of `lines.kml' > > using driver `LIBKML' successful. > > > > Layer name: SELECT > > Geometry: None > > Feature Count: 2 > > Layer SRS WKT: > > (unknown) > > st_length(geometry): Real (0.0) > > OGRFeature(SELECT):0 > > st_length(geometry) (Real) = 38.2726390753108 > > > > OGRFeature(SELECT):1 > > st_length(geometry) (Real) = 34.5939953221416 > > > > -Jukka Rahkonen- > > > > > > alok mathur wrote: > > > > Hi Rahkonen, > > > > I have a KML as data source and I am not using sqlite or postgis. > > I am reading the KML from ogrinfo. is there anyway to do the length > calculation without using sqlite or postgis. > > > > Thanks! > > Alok > > > > On Fri, Mar 13, 2015 at 3:28 PM, Rahkonen Jukka (MML) < > jukka.rahko...@maanmittauslaitos.fi> wrote: > > Hi Lars, > > > > You should not underestimate GDAL. Read > http://www.gdal.org/ogr_sql_sqlite.html and look at this: > > > > ogrinfo -dialect sqlite -sql "select st_length(geometry) from line_demo > limit 5" line_demo.shp > > INFO: Open of `line_demo.shp' > > using driver `ESRI Shapefile' successful. > > > > Layer name: SELECT > > Geometry: None > > Feature Count: 10 > > Layer SRS WKT: > > (unknown) > > st_length(geometry): Real (0.0) > > OGRFeature(SELECT):0 > > st_length(geometry) (Real) = 638.237633730745 > > OGRFeature(SELECT):1 > > st_length(geometry) (Real) = 32.7179011265525 > > OGRFeature(SELECT):2 > > st_length(geometry) (Real) = 4399.43983906202 > > OGRFeature(SELECT):3 > > st_length(geometry) (Real) = 480.395511976145 > > OGRFeature(SELECT):4 > > st_length(geometry) (Real) = 311.309421824364 > > -Jukka Rahkonen- > > > > > > Schylberg Lars wrote: > > > > As far as I know there is no length function in Mapserver. > > The only geometry function to use in Expressions is area(shape). > > OGR sql doesn’t provide that either as far as I can see in the > documentation. > > > > So the solutions might be to convert your KML data to sqlite or postgis > where such functions are available. > > > > The length of a string (number of characters in the string) can be found > in OGR sql with the length function, > but I am assuming You are looking for the geometric length of the > linestring. > > > > /Lars > > > > *From:* mapserver-users-boun...@lists.osgeo.org [ > mailto:mapserver-users-boun...@lists.osgeo.org > ] *On Behalf Of *alok mathur > *Sent:* den 13 mars 2015 07:01 > *To:* mapserver-users@lists.osgeo.org > *Subject:* [mapserver-users] Calculate length! > > > > Hi, > > > > I want to calculate the length in mapserver. Is it possible. Means i have > a linestring and i want to know the length for it. > > Also not could be suggest me how to do it. > > > > I am using data source to mapserver as KML. > > > > Thanks! > > > > -- > > *Alok Mathur* > > > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/mapserver-users > > > > > > -- > > *Alok Mathur* | Software Engineer 2A | Ciena > Mobile +91 9899413266 > -- *Alok Mathur* | Software Engineer 2A | Ciena Mobile +91 9899413266 ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
Hi Jukka, You were right about that is possible to calculate length of a line in a KML file in Mapserver via ogr and sqlite. It is possible with a VRT file. I had some weekend fun learning. This will be useful in another project I am doing! The only trouble I found, was that I could not get the relativeToVRT=1 to work when I did an inline specification of the ovf in the mapfile. The only way to get the inline ScrDataSource specification to work was to use a full path description to the kml file location. In most cases I like to use relative location specifications. Shapepath specification in the mapfile didn’t help /Lars Example follows: Make a ovf-file: doc_test.ovf ./doc_test.kml select geometry, Name, cast(OGR_STYLE as chartater(32)) as 'LINE_STYLE', cast(ST_length(geometry, 4857) as integer(12)) as 'DISTANCE' FROM 'Fibertech solution' where ST_GeometryType(geometry) LIKE 'LINESTRING%' The class from the new mapfile. LAYER CONNECTIONTYPE OGR CONNECTION "doc_test.ovf" DATA 'doc_test' NAME "kml_example" GROUP LINES TYPE LINE STATUS ON CLASSITEM "LINE_STYLE" CLASS EXPRESSION "@msn_ylw-pushpin4" STYLE COLOR 250 0 0 WIDTH 2.5 END LABEL TEXT ("Distance: " + '[DISTANCE]' + ' meters ' + '#' + '[Name]') WRAP '#' SIZE MEDIUM COLOR 255 100 100 POSITION AUTO END END ……. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
Hi Jukka, That is right and that is why I wrote about conversion to spatialite. Next questions is when it gets interesting. How can I get Mapserver to understand that it is sqlite dialect in the DATA statement? If this would be the case: CONNECTIONTYPE OGR CONNECTION "doc_test.kml" DATA "select st_length(geometry) from line_demo limit 5" As far as I understand it defaults to regular OGR sql. I was looking for an answer a couple of months ago but didn’t find any solution. Somewhere I have seen that pszDialect can be set to "SQLITE". But can that be done in the mapfile? I have also seen in old message from You about a undocumented workaround with VRT Is that the solution? I have a similar issue myself where I would like work against another OGR format but with sqlite syntax. /Lars From: Rahkonen Jukka (MML) [mailto:jukka.rahko...@maanmittauslaitos.fi] Sent: den 13 mars 2015 10:58 To: Schylberg Lars; mapserver-users@lists.osgeo.org Subject: Re: [mapserver-users] Calculate length! Hi Lars, You should not underestimate GDAL. Read http://www.gdal.org/ogr_sql_sqlite.html and look at this: ogrinfo -dialect sqlite -sql "select st_length(geometry) from line_demo limit 5" line_demo.shp INFO: Open of `line_demo.shp' using driver `ESRI Shapefile' successful. Layer name: SELECT Geometry: None Feature Count: 10 Layer SRS WKT: (unknown) st_length(geometry): Real (0.0) OGRFeature(SELECT):0 st_length(geometry) (Real) = 638.237633730745 OGRFeature(SELECT):1 st_length(geometry) (Real) = 32.7179011265525 OGRFeature(SELECT):2 st_length(geometry) (Real) = 4399.43983906202 OGRFeature(SELECT):3 st_length(geometry) (Real) = 480.395511976145 OGRFeature(SELECT):4 st_length(geometry) (Real) = 311.309421824364 -Jukka Rahkonen- Schylberg Lars wrote: As far as I know there is no length function in Mapserver. The only geometry function to use in Expressions is area(shape). OGR sql doesn’t provide that either as far as I can see in the documentation. So the solutions might be to convert your KML data to sqlite or postgis where such functions are available. The length of a string (number of characters in the string) can be found in OGR sql with the length function, but I am assuming You are looking for the geometric length of the linestring. /Lars From: mapserver-users-boun...@lists.osgeo.org<mailto:mapserver-users-boun...@lists.osgeo.org> [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of alok mathur Sent: den 13 mars 2015 07:01 To: mapserver-users@lists.osgeo.org<mailto:mapserver-users@lists.osgeo.org> Subject: [mapserver-users] Calculate length! Hi, I want to calculate the length in mapserver. Is it possible. Means i have a linestring and i want to know the length for it. Also not could be suggest me how to do it. I am using data source to mapserver as KML. Thanks! -- Alok Mathur ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
Hi Lars, You should not underestimate GDAL. Read http://www.gdal.org/ogr_sql_sqlite.html and look at this: ogrinfo -dialect sqlite -sql "select st_length(geometry) from line_demo limit 5" line_demo.shp INFO: Open of `line_demo.shp' using driver `ESRI Shapefile' successful. Layer name: SELECT Geometry: None Feature Count: 10 Layer SRS WKT: (unknown) st_length(geometry): Real (0.0) OGRFeature(SELECT):0 st_length(geometry) (Real) = 638.237633730745 OGRFeature(SELECT):1 st_length(geometry) (Real) = 32.7179011265525 OGRFeature(SELECT):2 st_length(geometry) (Real) = 4399.43983906202 OGRFeature(SELECT):3 st_length(geometry) (Real) = 480.395511976145 OGRFeature(SELECT):4 st_length(geometry) (Real) = 311.309421824364 -Jukka Rahkonen- Schylberg Lars wrote: As far as I know there is no length function in Mapserver. The only geometry function to use in Expressions is area(shape). OGR sql doesn’t provide that either as far as I can see in the documentation. So the solutions might be to convert your KML data to sqlite or postgis where such functions are available. The length of a string (number of characters in the string) can be found in OGR sql with the length function, but I am assuming You are looking for the geometric length of the linestring. /Lars From: mapserver-users-boun...@lists.osgeo.org<mailto:mapserver-users-boun...@lists.osgeo.org> [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of alok mathur Sent: den 13 mars 2015 07:01 To: mapserver-users@lists.osgeo.org<mailto:mapserver-users@lists.osgeo.org> Subject: [mapserver-users] Calculate length! Hi, I want to calculate the length in mapserver. Is it possible. Means i have a linestring and i want to know the length for it. Also not could be suggest me how to do it. I am using data source to mapserver as KML. Thanks! -- Alok Mathur ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
Thanks Lars. Yes I am looking for geometric length. On Fri, Mar 13, 2015 at 3:11 PM, Schylberg Lars < lars.schylb...@saabgroup.com> wrote: > As far as I know there is no length function in Mapserver. > > The only geometry function to use in Expressions is area(shape). > > OGR sql doesn’t provide that either as far as I can see in the > documentation. > > > > So the solutions might be to convert your KML data to sqlite or postgis > where such functions are available. > > > > The length of a string (number of characters in the string) can be found > in OGR sql with the length function, > but I am assuming You are looking for the geometric length of the > linestring. > > > > /Lars > > > > *From:* mapserver-users-boun...@lists.osgeo.org [mailto: > mapserver-users-boun...@lists.osgeo.org] *On Behalf Of *alok mathur > *Sent:* den 13 mars 2015 07:01 > *To:* mapserver-users@lists.osgeo.org > *Subject:* [mapserver-users] Calculate length! > > > > Hi, > > > > I want to calculate the length in mapserver. Is it possible. Means i have > a linestring and i want to know the length for it. > > Also not could be suggest me how to do it. > > > > I am using data source to mapserver as KML. > > > > Thanks! > > > > -- > > *Alok Mathur* > > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/mapserver-users > -- *Alok Mathur* | Software Engineer 2A | Ciena Mobile +91 9899413266 ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Calculate length!
As far as I know there is no length function in Mapserver. The only geometry function to use in Expressions is area(shape). OGR sql doesn’t provide that either as far as I can see in the documentation. So the solutions might be to convert your KML data to sqlite or postgis where such functions are available. The length of a string (number of characters in the string) can be found in OGR sql with the length function, but I am assuming You are looking for the geometric length of the linestring. /Lars From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of alok mathur Sent: den 13 mars 2015 07:01 To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Calculate length! Hi, I want to calculate the length in mapserver. Is it possible. Means i have a linestring and i want to know the length for it. Also not could be suggest me how to do it. I am using data source to mapserver as KML. Thanks! -- Alok Mathur ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
[mapserver-users] Calculate length!
Hi, I want to calculate the length in mapserver. Is it possible. Means i have a linestring and i want to know the length for it. Also not could be suggest me how to do it. I am using data source to mapserver as KML. Thanks! -- *Alok Mathur* ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users