Hacker Newsnew | past | comments | ask | show | jobs | submit | westnordost's commentslogin

The bitmap approach you describe allows for immediate (i.e. O(1) ) lookup of region by coordinate, which is pretty neat. Space-efficiency-wise, a bitmap (+ index that maps color to country) might not be the most efficient data structure, though, as there are more than 256 countries, so you already need 16 bits for each pixel instead of 8. Then, you have the additional complexity of if you actually want the bitmap to be viewable by humans, you need to make sure that the colors for neighbouring countries at least are sufficiently distinct.

Anyway, a Kotlin library I wrote uses a similar technique to make requests for the majority of locations immediate, while also handling the edge cases - i.e. when querying a location near a border.

https://github.com/westnordost/countryboundaries (also available in Rust)

What it does is to slice up the input geometry (e.g. a GeoJson) into many small cells in a raster. So, when querying for a location, one doesn't need to do point-in-polygon checks for potentially huge polygons, but just for those little slices that are in the cell one is querying for. And of course, if a country completely covers a cell, we don't even need to do any point-in-polygon check anymore. All this slicing is done in a preprocessing step, so the actual library consumes a serialized data structure that is already in this sliced-up format.

I needed it to be fast because in my app I display a lot of POIs on the map for which there is logic that is dependent on in which country/state the POI is located.


There are 249 countries with an iso code; so 8 bits might be enough. So it's not that bad. But even at 32 bits it would probably be fine and you could cram in some more data.

There are many similar things of course but nothing that was multiplatform, which I needed. I actually created a multiplatform kotlin library for working with language and country codes a few months ago: https://github.com/jillesvangurp/ko-iso

It seems we have some shared interests. I'll check out your library.

What you describe is nice strategy for indexing things. I've done some similar things. Another library (jillesvangurp/geogeometry) I maintain allows you to figure out which map tiles cover a polygon cover a polygon. Map tiles are nice because they are basically quad tree paths. I have a similar algorithm that does that with geohashes. You could use both for indexing geospatial stuff.

Slicing up the polygons sounds interesting. I've been meaning to have a go at intersect/union type operations on geometries. I added a boolean intersects recently to check whether geometries intersect each other. I already had containment check.


> There are 249 countries with an iso code; so 8 bits might be enough.

There are 249 ISO 3166-1 country codes:

* https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

But 193 sovereign states recognized by the UN:

* https://en.wikipedia.org/wiki/Member_states_of_the_United_Na...

Some of the discrepancy can be accounted for by "legacy" codes like .su for the Soviet Union.


> But 193 sovereign states recognized by the UN

All of which are also in the 249 ISO 3166-1 list; it's a super set. It doesn't include the historical ones anymore. Codes for those are interesting if you have old data perhaps.


Are you thinking of certain secondary libraries in particular?


You probably mean Compose Multiplatform?

That is a fork, or rather, extension to Jetpack Compose, Google's declarative UI framework for Android. It uses Skia for rendering but has an the identical API to Jetpack Compose, hence from the point of view of a framework user, there is nothing new about it (other than that it works on Android, iOS, desktop OSs and web).


Regarding data mining tools for OpenStreetMap, there is also a tool with which one can use SPARQL syntax. This means that one could conflate data with wikidata or other data sources easily, too:

QLever: https://qlever.cs.uni-freiburg.de/osm-planet

Actually, there are two. Sophox is around for longer:

Sophox: https://sophox.org/


The most accessible general-purpose map app for end users (Android and iOS) is written in C/C++. This is pretty high on the cool and useful scale: https://organicmaps.app/

Both map renderers Tangram-ES and Maplibre-GL - https://github.com/tangrams/tangram-es and - https://github.com/maplibre/maplibre-gl-native are also written in C/C++.

Finally, most routing software, such as OSRM or Valhalla are written in C/C++.


I find mapy.cz to be smoother. Not sure what its written in though as its not open source.

Android: https://play.google.com/store/apps/details?id=cz.seznam.mapy...

iOS: https://apps.apple.com/cz/app/mapy-cz/id411411020


Just for context, here is the current OSM data model in a nutshell:

There are three data types - nodes, ways and relations. All of the three can have any number of "tags" (i.e. a map<string, string>), which define their semantic meaning. For example, a way with `barrier=fence` is a fence. This stuff is documented in the openstreetmap wiki.

A node is a point with a longitude and a latitude.

A way is a sequence of nodes.

A relation is a collections of any number of nodes, ways or other relations. Each member of this collection can be assigned a "role" (string). Again, the semantics of what each role means is documented in the openstreetmap wiki.

To modify data, simply new versions of the edited data are uploaded via the API.

---

The most prominent point that stands out here is that only nodes have actual geometry.

This means that...

1. to get the geometry of a way (e.g a building, a road, a landuse, ...), data users first need to get the locations of all the nodes the way references. For relations, it is even one more step.

2. in order to edit the course of a way, editors actually edit the location of the nodes of which the way consists of, not the way itself. This means (amongst other things) that the VCS history of that way does not contain such changes


Where the SDK pulls its data from is not hardcoded.

The SDK is just a library, used to render vector map tiles, usually in the MVT-format: https://docs.mapbox.com/vector-tiles/specification/

Most maps rendered with such an SDK are based on OpenStreetMap data.


If it is true that Apple will soon drop OpenGL and only support Metal:

Will the SDK also work on iOS and Mac then, i.e. has Metal support?


There is active development on a Metal-supporting version, yes!

https://github.com/maplibre/maplibre-gl-native/tree/metal-su... is the branch and https://github.com/maplibre/maplibre-gl-native/issues?q=is%3... are associated issues.


Yes, we have a beta build of the SDK with Metal support (https://github.com/maplibre/maplibre-gl-native/tree/metal-su..., https://github.com/maplibre/maplibre-gl-native/releases/tag/...). There are some minor issues we are addressing in the new release. Contributors and brave souls willing to try out the build are more than welcome :).


(Author here:) I got many emails about new patrons/sponsors yesterday and was astonished where this was all coming from, now I know!

Thank you for posting this and thank you all for your support! This helps me a lot to find the time to maintain the app, in general a kind of work that I think is often underestimated, also in terms of time invested.

For example, Google recently kicked the app out of their app store for spurious reasons so I had to act quickly to get it back ASAP. I kept track of the issue (and am still updating it, it's not over yet) here:

https://github.com/streetcomplete/StreetComplete/issues/2909

This may be an interesting read and shed some light on how the Google Play Store team works and handles policy violations and appeals.


Doesn't it run in anbox?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: