[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.orgmailto: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.orgmailto: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!
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
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] Odd warning in WFS GetCapabilities ~ what's missing in the config?
Hi, It looks that at the moment this GetCapabilities is not valid: http://194.66.252.155/cgi-bin/BGS_OGE_Bedrock_and_Surface_Geology_in2/ows?service=WFSrequest=GetCapabilitiesversion=1.1.0 The WFS 1.1.0 schema contains xsd:choice xsd:sequence xsd:element name=DefaultSRS type=xsd:anyURI/ xsd:element name=OtherSRS type=xsd:anyURI minOccurs=0 maxOccurs=unbounded /xsd:sequence xsd:element name=NoSRS xsd:complexType/ /xsd:element /xsd:choice So, there must be either DefaultSRS or then NoSRS advertised, and with DefaultSRS optionally a list of OtherSRS. Standard says that if srsname is not included in the request then the DefaultSRS is used, and that is advertised in the OtherSRS list must be supported. However, it does not say what should happen if request contains an unknown srsname (SRSNAME=UGH:00). Somehow I would like to see an error message but your Mapserver selects to use the default SRS. Here is part of the standard: The optional srsName attribute of the Query element is used to specify a specific WFS-supported SRS to be used for returned feature geometries. Its value may be the DefaultSRS or any of the OtherSRS values listed for the feature type in WFS capabilities document. If no srsName value is supplied, then the features shall be returned using the advertised DefaultSRS value. This attribute has no meaning for feature types with no spatial properties; if an srsName value is specified for a feature with no spatial properties, a web feature service may ignore the parameter and its value. Any valid URI value can be assigned to the srsName attribute. However, in order to enhance interoperability, a web feature service must be able to process srsName attribute values with the following format models... I suggest to go on with testing and make a bug report if you can confirm with a reproducible way that DefaultSRS is missing. -Jukka Rahkonen- Passmore, James H. wrote: Hi Jukka, Thanks for persevering with this. OK, so, the issue is not that I'm not using a shapefile (I'm using an OGR connection to an ESRI Geodatabase), or per se that I specified a list of SRS (the documentation shows a WFS_SRS list), but it is to do with the first cited SRS in the list. So this original WEB METADATA OWS_SRS CRS:84 EPSG:27700 EPSG:3034 EPSG:4258 EPSG:4326 fails but his works (that is the error message in the GetCapabilities goes away) WEB METADATA OWS_SRS EPSG:4326 CRS:84 EPSG:27700 EPSG:3034 EPSG:4258 with no need to specify an OWS/WFS LAYER METADATA section. So the error message occurs when an unrecognized SRS is specified first. As I understand it the processing precedence (assuming everything is otherwise correct) is: MAP.WEB.METADATA.WFS_SRS (if this doesn't exist then check next) MAP.WEB.METADATA.OWS_SRS (if this doesn't exist then check next) MAP.PROJECTION (if this doesn't exist then check for the Feature) LAYER.METADATA.WFS_SRS LAYER.METADATA.OWS_SRS LAYER.PROJECTION If none then you get error: !-- WARNING: Mandatory mapfile parameter: (at least one of) MAP.PROJECTION, LAYER.PROJECTION or wfs/ows_srs metadata was missing in this context. -- There does appear to be a different processing precedence if there is some issue with the SRS, in such a situation you get: MAP.WEB.METADATA.WFS_SRS (if this has error then check next) MAP.WEB.METADATA.OWS_SRS (if this has error then check for the Feature) LAYER.METADATA.WFS_SRS (if this has error then check next) LAYER.METADATA.OWS_SRS If there is still an error/issue you get the same (now misleading) message: !-- WARNING: Mandatory mapfile parameter: (at least one of) MAP.PROJECTION, LAYER.PROJECTION or wfs/ows_srs metadata was missing in this context. -- I say misleading because MAP.PROJECTION, LAYER.PROJECTION are set here (EPSG:4326) but are ignored. It is further misleading because ows_srs metadata is also set. As I stated the service was working even with the warning in place (I think QGIS must just assume CRS:84 support because it isn't reported) e.g. this request 'works': http://194.66.252.155/cgi-bin/BGS_OGE_Bedrock_and_Surface_Geology_in2/ows?SERVICE=WFSVERSION=1.0.0REQUEST=GetFeatureTYPENAME=GE.GeologicFault.BGS.EN.1M.BedrockSRSNAME=CRS:84 Really I am surprised that MapServer has been able to serve the request at all, but looking closer I see that I haven't got a CRS:84 response at all, what I have is an EPSG:4326 response, in fact I can specify any unrecognized SRSNAME and I get an EPSG:4326 response For example: http://194.66.252.155/cgi-bin/BGS_OGE_Bedrock_and_Surface_Geology_in2/ows?SERVICE=WFSVERSION=1.0.0REQUEST=GetFeatureTYPENAME=GE.GeologicFault.BGS.EN.1M.BedrockSRSNAME=UGH:00. To me it looks like in the background MapServer must look at MAP.PROJECTION or LAYER.PROJECTION despite the error message, or else it must assume EPSG:4326 as a default. Cheers James This message (and any attachments) is for the recipient only. NERC is subject
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.orgmailto: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.orgmailto: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] Odd warning in WFS GetCapabilities ~ what's missing in the config?
Hi Jukka, Thanks for persevering with this. OK, so, the issue is not that I'm not using a shapefile (I'm using an OGR connection to an ESRI Geodatabase), or per se that I specified a list of SRS (the documentation shows a WFS_SRS list), but it is to do with the first cited SRS in the list. So this original WEB METADATA OWS_SRS CRS:84 EPSG:27700 EPSG:3034 EPSG:4258 EPSG:4326 fails but his works (that is the error message in the GetCapabilities goes away) WEB METADATA OWS_SRS EPSG:4326 CRS:84 EPSG:27700 EPSG:3034 EPSG:4258 with no need to specify an OWS/WFS LAYER METADATA section. So the error message occurs when an unrecognized SRS is specified first. As I understand it the processing precedence (assuming everything is otherwise correct) is: MAP.WEB.METADATA.WFS_SRS (if this doesn't exist then check next) MAP.WEB.METADATA.OWS_SRS (if this doesn't exist then check next) MAP.PROJECTION (if this doesn't exist then check for the Feature) LAYER.METADATA.WFS_SRS LAYER.METADATA.OWS_SRS LAYER.PROJECTION If none then you get error: !-- WARNING: Mandatory mapfile parameter: (at least one of) MAP.PROJECTION, LAYER.PROJECTION or wfs/ows_srs metadata was missing in this context. -- There does appear to be a different processing precedence if there is some issue with the SRS, in such a situation you get: MAP.WEB.METADATA.WFS_SRS (if this has error then check next) MAP.WEB.METADATA.OWS_SRS (if this has error then check for the Feature) LAYER.METADATA.WFS_SRS (if this has error then check next) LAYER.METADATA.OWS_SRS If there is still an error/issue you get the same (now misleading) message: !-- WARNING: Mandatory mapfile parameter: (at least one of) MAP.PROJECTION, LAYER.PROJECTION or wfs/ows_srs metadata was missing in this context. -- I say misleading because MAP.PROJECTION, LAYER.PROJECTION are set here (EPSG:4326) but are ignored. It is further misleading because ows_srs metadata is also set. As I stated the service was working even with the warning in place (I think QGIS must just assume CRS:84 support because it isn't reported) e.g. this request 'works': http://194.66.252.155/cgi-bin/BGS_OGE_Bedrock_and_Surface_Geology_in2/ows?SERVICE=WFSVERSION=1.0.0REQUEST=GetFeatureTYPENAME=GE.GeologicFault.BGS.EN.1M.BedrockSRSNAME=CRS:84 Really I am surprised that MapServer has been able to serve the request at all, but looking closer I see that I haven't got a CRS:84 response at all, what I have is an EPSG:4326 response, in fact I can specify any unrecognized SRSNAME and I get an EPSG:4326 response For example: http://194.66.252.155/cgi-bin/BGS_OGE_Bedrock_and_Surface_Geology_in2/ows?SERVICE=WFSVERSION=1.0.0REQUEST=GetFeatureTYPENAME=GE.GeologicFault.BGS.EN.1M.BedrockSRSNAME=UGH:00. To me it looks like in the background MapServer must look at MAP.PROJECTION or LAYER.PROJECTION despite the error message, or else it must assume EPSG:4326 as a default. Cheers James This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users