[mapserver-users] Arc symbol.
lars.schylberg at blixtmail.se
lars.schylberg at blixtmail.se
Tue Mar 12 14:15:53 PDT 2019
Hi again Marek,
I You are doing S-57 LÍGHTS layer. That is exacly what we are doing in the SMAC-M project: https://github.com/LarsSchy/SMAC-M (https://github.com/LarsSchy/SMAC-M)
We have a solution for doing S-57 charts with Mapserver. Both preparing data and generate mapfiles.
Your specific question is solved with the preprocessing step in: https://github.com/LarsSchy/SMAC-M/blob/master/chart-installation/data_files_conversion/shp_s57data/generate_light_sector.py (https://github.com/LarsSchy/SMAC-M/blob/master/chart-installation/data_files_conversion/shp_s57data/generate_light_sector.py)
Best regards
Lars Schylberg
March 12, 2019 6:17 PM, "Marek Bąk" <rainy3 at poczta.onet.pl (mailto:rainy3 at poczta.onet.pl?to=%22Marek%20B%C4%85k%22%20<rainy3 at poczta.onet.pl>)> wrote:
Hi All,
Thanks for all suggestions and ideas. I've evaluated them using the ms4w binaries (v3.3.0):
- there is no support for V8 at the moment (unless built from sources),
- adding ST_Project to spatialite library is on roadmap (at the moment you need to compile spatialite library yourself),
- I failed with CIRCULARSTRING - when I used select with ST_GeomFromText and CIRCULARSTRING as geometry the result was null (I guess that I've missed something),
- I did not test PostGIS but I think that it should work (I guess all required function are there).
Instead of all above, since I'm working on S-57 LIGHTS layer and I've already needed a shape file for storing each light description, I've decided to convert S-57 ENC LIGHTS layer to two shape files (one for POINTS and one for LINES). I still need to tweak that solution but it seems to work (one layer became physically two but since I'm using GROUP attribute in LAYER object logically it was one to one conversion).
Regards,
Marek
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/20190312/b346268a/attachment.htm>
More information about the MapServer-users
mailing list