[mapserver-users] KML reading through OGR

alok mathur mathuralok.88 at gmail.com
Thu Mar 12 02:57:20 PDT 2015


Hi Lars,

I want to create a styling for each placemark  in .map file. Means If i
have a KML containing one folder with multiple placemarks as shown below. I
want to create a .map file which will contain style for each placemark.
What if i have the same names of placemarks. Please help me to get the
solution

Eg.

KML
----------------

<Folder>
<name>NE Third Route</name>
<Folder>
<name>Fibertech solution</name>
<Placemark>
<name>Westborough MSC - Build</name>
<styleUrl>#msn_ylw-pushpin4</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-71.58570500983306,42.28745742866225,0
-71.58563778135751,42.28308954118536,0
-71.58466087108053,42.28307704913402,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Westborough MSC to Westborugh</name>
<styleUrl>#msn_ylw-pushpin8</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-71.62172195712955,42.27186897741407,0
-71.62194000095552,42.27189433043378,0
-71.6225634332947,42.27210480296427,0
-71.62308968672842,42.27236391420707,0
-71.62394597288645,42.27309147863262,0
-71.62737594489003,42.27740640295431,0
-71.62822373584245,42.27893783334968,0
-71.63091971519079,42.28164762788888,0
-71.63207040059587,42.28370221254578,0
-71.62599732629406,42.28418518334991,0
-71.60795611539982,42.28517668969011,0
-71.60267209851122,42.28504601944216,0
-71.60188701357249,42.28516492137062,0
-71.58850360403626,42.28849573666959,0
-71.5858004650346,42.28852197680775,0 -71.58571706491037,42.2874804233345,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>NEW Danbury</name>
<Camera>
<longitude>-73.45375129836707</longitude>
<latitude>41.390460041635</latitude>
<altitude>419.0806930250601</altitude>
<heading>13.43312150541231</heading>
<tilt>28.58299225276625</tilt>
<roll>-0.685026358787494</roll>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</Camera>
<styleUrl>#msn_ylw-stars</styleUrl>
<Point>
<gx:drawOrder>1</gx:drawOrder>
<coordinates>-73.45404626023216,41.3929335947184,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>NEW Scotland Amp</name>
<LookAt>
<longitude>-72.09703050755105</longitude>
<latitude>41.69579944328172</latitude>
<altitude>0</altitude>
<heading>-0.790587312931665</heading>
<tilt>19.0106770482321</tilt>
<range>445.0511788150669</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#msn_ylw-stars</styleUrl>
<Point>
<gx:drawOrder>1</gx:drawOrder>
<coordinates>-72.09643061038489,41.6960553015771,0</coordinates>
</Point>
</Placemark>
</Folder>





On Wed, Mar 11, 2015 at 6:38 PM, Schylberg Lars <
lars.schylberg at saabgroup.com> wrote:

>  The OGR style is the variable that is returned in the variable that is
> casted.
>
> Please look at the Layer definitions that I sent yesterday in the mapfile
> example.
>
>
>
> DATA "SELECT Name as NAME, CAST(OGR_STYLE AS character(32)) AS STYLE FROM
> 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING'"
>
> CLASSITEM "STYLE"
>
> LABELITEM "NAME"
>
>
>
> CLASS
>
>      EXPRESSION "@msn_ylw-pushpin4"
>
>
>
>
>
> That is the STYLE value used in the CLASSITEM expression.
>
>
>
> The description is shown in the label that uses the labelitem.  Also shown
> in the mapfile example yesterday.
>
>
>
>
>
> If You only want to get the features with the style ‘@msn_ylw-pushpin4'
> with ogrinfo you should write it like this:
>
>
>
> ogrinfo -ro doc_test.kml \
> -sql "SELECT *, CAST(OGR_STYLE AS character(255)) AS STYLE FROM 'Fibertech
> solution' \
> WHERE OGR_GEOMETRY='LINESTRING' AND OGR_STYLE='@msn_ylw-pushpin4'" –al
>
>
>
> That returns the geometry and variables according to this criteria, i.e.
> only lines and specific style.
>
>
>
> But I guess that You most likely would like to do this filtering in the
> Class section of the mapfile and not in the DATA statement.
>
>
>
> /Lars
>
>
>
>
>
> *From:* mapserver-users-bounces at lists.osgeo.org [mailto:
> mapserver-users-bounces at lists.osgeo.org] *On Behalf Of *alok mathur
> *Sent:* den 11 mars 2015 05:46
> *To:* mapserver-users at lists.osgeo.org
> *Subject:* [mapserver-users] KML reading through OGR
>
>
>
> Hi,
>
>
>
> I am unable to get the Styleurl using Ogrinfo. I am trying the command
>
> ogrinfo -al doc_test.kml -where "ogr_style='@msn_ylw-pushpin4'"
>
>
>
> but the result is
>
> Layer name: Fibertech solution
>
> Geometry: 3D Unknown (any)
>
> Feature Count: 0
>
> Layer SRS WKT:
>
> GEOGCS["WGS 84",
>
>     DATUM["WGS_1984",
>
>         SPHEROID["WGS 84",6378137,298.257223563,
>
>             AUTHORITY["EPSG","7030"]],
>
>         TOWGS84[0,0,0,0,0,0,0],
>
>         AUTHORITY["EPSG","6326"]],
>
>     PRIMEM["Greenwich",0,
>
>         AUTHORITY["EPSG","8901"]],
>
>     UNIT["degree",0.0174532925199433,
>
>         AUTHORITY["EPSG","9108"]],
>
>     AUTHORITY["EPSG","4326"]]
>
> Name: String (0.0)
>
> Description: String (0.0)
>
>
>
>
>
>
>
> Also i want to show the description of placemark on map.
>
>
>
> Thanks!
>
>
>
> --
>
> *Alok Mathur* | Software Engineer 2A | Ciena
> Mobile +91 9899413266
>



-- 

*Alok Mathur* | Software Engineer 2A | Ciena
Mobile +91 9899413266
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20150312/8e374fe9/attachment-0001.html>


More information about the mapserver-users mailing list