Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/clarisma/geodesk

Fast and storage-efficient spatial database engine for OpenStreetMap data
https://github.com/clarisma/geodesk

database geodesk geospatial gis openstreetmap

Last synced: 5 days ago
JSON representation

Fast and storage-efficient spatial database engine for OpenStreetMap data

Awesome Lists containing this project

README

        

GeoDesk is a fast and storage-efficient geospatial database for OpenStreetMap data. Also available [for C++](https://github.com/clarisma/libgeodesk) and [for Python](https://github.com/clarisma/geodesk-py).

## Why GeoDesk?

- **Small storage footprint** — GeoDesk's GOL files are only 20% to 50% larger than the original OSM data in PBF format — that's less than a tenth of the storage consumed by a traditional SQL-based database.

- **Fast queries** — typically 50 times faster than SQL.

- **Fast to get started** — Converting `.osm.pbf` data to a GOL is 20 times faster than an import into an SQL database. Alternatively, download pre-made data tiles for just the regions you need and automatically assemble them into a GOL.

- **Intuitive API** — No need for object-relational mapping; GeoDesk queries return `Node`, `Way` and `Relation` objects. Quickly discover tags, way-nodes and relation members. Get a feature's `Geometry`, measure its length/area.

- **Proper handling of relations** — (Traditional geospatial databases deal with geometric shapes and require workarounds to support this unique and powerful aspect of OSM data.)

- **Seamless integration with the Java Topology Suite (JTS)** for advanced geometric operations, such as buffer, union, simplify, convex and concave hulls, Voronoi diagrams, and much more.

- **Modest hardware requirements** — If it can run a 64-bit JVM, it'll run GeoDesk.

## Get Started

### Maven

Include this dependency in your project's `pom.xml`:

```xml

com.geodesk
geodesk
0.2.1

```

Alternatively, to build the latest version from source:

```
git clone https://github.com/clarisma/geodesk.git
cd geodesk
mvn install
```

*If you get weird exceptions during `mvn install`, you should [upgrade Maven](https://maven.apache.org/download.cgi) to version **3.8.5** or above.*

### Example Application

```java
import com.geodesk.feature.*;
import com.geodesk.util.*;

public class PubsExample
{
public static void main(String[] args)
{
FeatureLibrary library = new FeatureLibrary( // 1
"example.gol", // 2
"https://data.geodesk.com/switzerland"); // 3

for(Feature pub: library // 4
.select("na[amenity=pub]") // 5
.in(Box.ofWSEN(8.53,47.36,8.55,47.38))) // 6
{
System.out.println(pub.stringValue("name")); // 7
}

library.close(); // 8
}
}
```

What's going on here?

1. We're opening a feature library ...

2. ... with the file name `example.gol` (If it doesn't exist, a blank one is created)

3. ... and a URL from which [data tiles](https://docs.geodesk.com/libraries) will be downloaded.

4. We iterate through all the features ...

5. ... that are pubs ([GeoDesk query language](https://docs.geodesk.com/goql) — *similar to MapCSS*)

6. ... in downtown Zurich (*bounding box with West/South/East/North coordinates*).

7. We print the name of each pub.

8. We close the library.

That's it, you've created your first GeoDesk application!

### More Examples

Find all movie theaters within 500 meters from a given point:

```java
Features movieTheaters = library
.select("na[amenity=cinema]")
.maxMetersFromLonLat(500, myLon, myLat);
```

*Remember, OSM uses British English for its terminology.*

Discover the bus routes that traverse a given street:

```java
for(Feature route: street.parents("[route=bus]"))
{
System.out.format("- %s from %s to %s",
route.stringValue("ref"),
route.stringValue("from"),
route.stringValue("To"));
}
```

Count the number of entrances of a building:

```java
int numberOfEntrances = building.nodes("[entrance]").size();
```

## Documentation

- [GeoDesk Developer's Guide](https://docs.geodesk.com/java)
- [API Reference](https://apidocs.geodesk.com/0.2)

## Related Repositories

- [gol-tool](http://www.github.com/clarisma/gol-tool) — command-line utility for building, maintaining and querying GOL files
- [geodesk-examples](http://www.github.com/clarisma/geodesk-examples) — example applications
- [geodesk-tests](http://www.github.com/clarisma/geodesk-tests) — integration tests
- [libgeodesk](https://github.com/clarisma/libgeodesk) — GeoDesk for C++
- [geodesk-py](https://github.com/clarisma/geodesk-py) — GeoDesk for Python