[mapserver-users] Arc symbol.

lars.schylberg at blixtmail.se lars.schylberg at blixtmail.se
Wed Mar 6 11:29:04 PST 2019


Hi Marek,

This is a way of making arcs in Mapserver that is based on using VRTs and sql
The data source doesn't need to be in spatialite though. It can be a shapefile
or a CSV file or anything that gdal can handle.

Simon Mercier at Mapgears and I developed this for making litehouse circles
for Sea charts a couple of years ago. In the current version of the
SMAC-M project this is done with preprocessing in another way.

But I still like the idea that You can draw anything with sql.

I was going to make a small separate example this morning.
But I ran into some problems. It seems like my current gdal is not
compiled with a version of libspatialite that should use
librttopo instead of the lwgeom. In the version I used before I had the
sql function ST_project. In the version I had today on my machine and in some docker
containers I didn't. I guess I have to build a gdal-mapserver with
the right libspatialite and librttopo versions where I can do
these trix again some time.

Anyway this is the VRT file that can draw an arc in Mapserver.
The data source contains points in EPSG 4326 and we are drawing the arc
in EPSG 3857 in this case. valnmr is the radius and sectr1 and sectr2 are
starting and ending angles of the arc.

To use the vrt in mapserver you use:

 CONNECTION "arc.vrt"
 CONNECTIONTYPE OGR
 DATA "arc"

###### arc.vrt #####
<OGRVRTLayer name='arc'>
 <SrcDataSource>coastal.sqlite</SrcDataSource>
 <SrcSQL dialect='sqlite'>
 SELECT rcid,fidn,valnmr,sectr1,sectr2,colour,SIGGRP,SIGPER,HEIGHT,
 MakeArc(ST_X(Transform(Geometry,3857)),ST_Y(Transform(Geometry,3857)),
 GLength(Transform(MakeLine( MakePoint( X(Geometry), Y(Geometry),4326),
 ST_Project( MakePoint( X(Geometry), Y(Geometry), 4326 ),
 valnmr*1852/10, Radians( sectr1-180 ))),3857)),
 (180-(sectr2-90)),(180-(sectr1-90)),3857,2) AS geometry
 FROM lights_point
 WHERE sectr1 NOT NULL AND sectr2 NOT NULL AND sectr1!=0 AND sectr2!=360
 </SrcSQL>
</OGRVRTLayer>
#######################

If You would like to check what version of various libraries that You
have, You can use this VRT and run ogrinfo on it. E.g ogrinfo debug.vrt debug

##### debug.vrt #####
 <OGRVRTDataSource>
 <OGRVRTLayer name='debug'>
 <SrcDataSource>coastal.sqlite</SrcDataSource>
 <SrcSQL dialect='sqlite'>
 select
 sqlite_version(),
 spatialite_version(),
 lwgeom_version(),
 geos_version(),
 proj4_version()
 FROM lights_point
 </SrcSQL>
 </OGRVRTLayer>
##################### 

Have fun !

Lars Schylberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190306/981735c0/attachment.html>


More information about the mapserver-users mailing list