Use KML file to detect Countries (Xcode) - iphone

I have a KML file with all the countries and polygons. I am trying to create an app that get a Lat & Lon and detecting in which country belongs using this KML. I tried SimpleKML and KMLViewer with no luck.
The kml structure is:
<Document>
<Folder>
<Folder>
<name>A -</name>
<Placemark>
<name>Afghanistan</name>
<description></description>
<Style>
<PolyStyle>
<color>aaffffff</color>
<colorMode>random</colorMode>
</PolyStyle>
</Style>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
65.62729644775391,37.33319854736328,0 65.64692687988283,37.45888137817383,0
...
...
coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Albania</name>
..
..
..
1) It would be better to use xml parser and save the data on a local database?
2)Is there any function to determine in which polygonal is the given lat/lon ?
Thank you

The parsing should be pretty easy using NSXMLParser, look for names and associate them with coordinates. The more interesting part is to test the polygons for inclusion of a point.
Here's a highly regarded SO article, that looks like it borrows somewhat from this wikipedia article. What you would do is build a collection of polygons, and enumerate them testing each for the inclusion of some given coordinates.
The other thing to think about is to skip the parsing and polygon testing altogether and use the google geocoding api. This section talks specifically about getting address info (including country) from a latitude and longitude.

Related

Where to get polygons for german postcodes (from OSM, in GeoJSON)?

I want to draw a choropleth map based on german zipcode areas and some data.
It should look like this, just down to zipcodes:
https://maps.aimpulse.com/osm/addresses/
I asked the osm irc channel and have been told that it might even be possible with leaflet.js
So I read a bit here and there but I couldn't even find any starting point.
So any ideas are welcome.
Edit: Thanks to the answer and comment so far I think my main question is:
How do I get a list of german zipcode/postcode areas, with the corresponding coordinates for the polygons?
According to the irc channel, OpenStreetMap (OSM) has this data, and it should be possible to have it in GeoJSON format.
Yep, you could/should use leaflet.js.
You simply can create a map and add osm as TileLayer. After adding OSM tilelayer you can add your zipcode information.
The question is: how do you get them?
If you have the data as file (geojson) you can add a geojson layer.
leaflet.js has many other options to add the zipcode information.
I am quite sure that leaflet.js can do the trick.
So you can start with:
var map = L.map('map').setView([50.106545, 8.638599], 15);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
Now it depends on your zipcode-data how to implement them in leaflet.
Now I get it!
Getting those information is quite difficult!
You can try getting the zipcodes from the "Geoportal" - probably using the search word "Verwaltungsgrenzen".
Otherwise you can have a look at the OSM Boundaries. But those informations are incomplete.
The german "post office" also hold those data, but this might be expensive!
I've found this repository with that information, I don't know if it is updated but works.

ArcGIS character marker in geoserver

Does anyone have any experience using ESRI ArcGIS character marker symbols for point datasets in Geoserver for online map publishing. The character symbols I am interested in using is from the 'ESRI Enviro Hazard Sites' symbols for dolphin, manatee and whale.
Any advise would be much appreciated!
Jason
You may be able to by using the < ExternalGraphic> tag in the SLD instead of a simple shape such as circle or square. Here is a sample from GeoServers SLD Cookbook section point as graphic.
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="smileyface.png" />
<Format>image/png</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>

Openstreetmap (Overpass API): Get nearest Node with a special tag

I got a point on my map and now I'm just trying to get the name of the city (or suburb) in which the point is. My first attempt was like this:
<query type="node">
<bbox-query {{bbox}}/>
<has-kv k="place" v="suburb"/>
</query>
<print/>
But this won't work for me, if the suburb-node isn't in my bounding-box. Is there something like an around-, nearest- or is-in-condition to get this node?
Thanks a lot!
If you are looking for the city, country or an otherwise named place a given coordinate is in, then you are better of using a geocoder. Nominatim provides geocoding capabilities based on OSM data.
To answer your original question: If the feature you are searching for is not inside the bounding box, then you can of course just try extending the bounding box. But there is also an around keyword for searching something near something else. Note that this will return all data matching the given tags, not just the closest one to your given point. Furthermore because Overpass is not a geocoder it won't work correctly for features mapped as an area or relation instead of a simple node.

Remove street numbers from OSM maps

I'm still working on my map project. I use mapnik tools to render my own maps.
Mapnik reads a xml file to style each tiles.
At this moment, i managed to remove street names and all stuff that was useless for my project. The only problem i have is about removing the street numbers, which still appear even when all useless layers are off.
I give you a pastebin link to my xml file: http://pastebin.com/ZRtmYBRz.
Do you know how i can remove the street numbers ? Thanks.
Before :
Now:
Try using a filter on the addr:housenumber tag of the nodes in the source file that contain that info. Once you get those, you can change the rendering by using a TextSymbolizer.
More info on https://github.com/mapnik/mapnik/wiki/TextSymbolizer

Saving Long/Lat as kml (track)

So, I've got a class with contains a NSMutableArray of CLLocation's, and a name.
Now I want to save them to KML, ideally as a track (or , so I can use the file to display the locations traveled.)
How would I go about this?
I don't expect code, more guidance (I'm new to Objective-C and KML, so got a lot to learn! :) )
I haven't used either of these, but here's a couple of libraries that turned up in a search:
http://github.com/incanus/Simple-KML/
http://developmentseed.org/blog/2010/aug/12/kml-parsing-library-released-apples-ios-platform
Edit: it looks like both those libraries are parsers, not writers. You may have to create your own writer.
I'd say that using either of these libraries would save you a lot of time. That said, have a look at how KML is formed. It's just XML and making a track is really easy. Here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1" xmlns:trails="http://www.google.com/kml/trails/1.0">
<Document>
<name>RK_Running.kml</name>
<Placemark>
<name>Running 12/9</name>
<Style>
<LineStyle>
<color>ff0000ff</color>
<width>4</width>
</LineStyle>
</Style>
<MultiGeometry>
<LineString>
<tessellate>1</tessellate>
<coordinates>
138.968309,35.716577,17.0
138.967998,35.716859,17.0
138.967526,35.717252,20.0
138.967055,35.717494,20.0
</coordinates>
</LineString>
</MultiGeometry>
</Placemark>
</Document>
</kml>
Save this as a .kml and it will open in Google Earth
KML is just XML. I'd suggest you create something like what you're looking for using Google Earth. Save it as KML and open it with a text editor to get an idea of what you need to output.
You can generate XML using libxml2 or KissXML