OsmDataKit 3.1.1

dotnet add package OsmDataKit --version 3.1.1
NuGet\Install-Package OsmDataKit -Version 3.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OsmDataKit" Version="3.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OsmDataKit --version 3.1.1
#r "nuget: OsmDataKit, 3.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OsmDataKit as a Cake Addin
#addin nuget:?package=OsmDataKit&version=3.1.1

// Install OsmDataKit as a Cake Tool
#tool nuget:?package=OsmDataKit&version=3.1.1

OsmDataKit project OsmDataKit

NuGet package MIT license Nuget downloads GitHub stars <br><br>

The OsmDataKit is a tool for convenient work with the OpenStreetMap database. Allows loading from a PBF file a set of elementary objects as well as nested tree structures. It caches load results. Resistant to the integrity violations of the base. Saves RAM, allows you to work with whole continents.

Problems in OsmSharp and their solution in OsmDataKit:
  1. Lack of RAM. OsmSharp uses the principle of “loading the entire database into RAM, and we’ll figure it out” to build complete objects. Even working with a small country, you can easily use up 16 GB of RAM. But what if you need the whole world?

    • Solution. OsmDataKit makes three loads from the database sequentially to build complete objects. In uses only the necessary minimum of information, such as coordinates, tags and relationships between elements.
  2. Crash on integrity violation. There are inevitably some integrity violations in the OSM database. For example, one Way may lose one Node. In this situation, OsmSharp will crash and you won’t get anything.

    • Solution. If there is no element in the database, OsmDataKit will still construct a complete object, convenient for use in your project. Information on all missed elements will be available in the load results.
  3. Complex and inconvenient requests. When using OsmSharp, you cannot just make a conceptual query and get what you need. It is required to specify in the request absolutely all elements that potentially may be part of complete objects. Any mistake you make will result in a crash.

    • Solution. When using OsmDataKit, you need to specify the minimum information in the request. All dependent elements upon loading will be automatically found and assembled into complete objects. <br><br><br>

<a name="install"></a>Install

PM> Install-Package OsmDataKit

<br>

<a name="usage"></a>Usage

using OsmDataKit;

// Sample queries by filter and by ID’s
bool requestByFilter(OsmGeo geo) => geo.Tags.ContainsKey("place");
var requestByIds = new GeoRequest(nodeIds, wayIds, relationIds);

// Loading elementary geo objects
GeoObjectSet geosByFilter = OsmService.LoadObjects(pathToPbf, requestByFilter);
GeoObjectSet geosByIds = OsmService.LoadObjects(pathToPbf, requestByIds);

// Loading complete geo objects
CompleteGeoObjects completeByFilter = OsmService.LoadCompleteObjects(pathToPbf, requestByFilter);
CompleteGeoObjects completeByIds = OsmService.LoadCompleteObjects(pathToPbf, requestByIds);

<br>

The result of loading elementary geo objects will be the class GeoObjectSet. It contains flat lists of all the geo objects found by your request. Also contains the ID’s of objects not found in the database.

class GeoObjectSet
{
  NodeObject[] Nodes
  WayObject[] Ways
  RelationObject[] Relations
  long[] MissedNodeIds
  long[] MissedWayIds
  long[] MissedRelationIds
}

<br>

The result of loading complete geo objects will be the class CompleteGeoObjects. It contains top-level geo objects, and all other elements are nested in a tree, according to their conceptual hierarchy. Also contains the ID’s of objects not found in the database.

class CompleteGeoObjects
{
  NodeObject[] RootNodes
  WayObject[] RootWays
  RelationObject[] RootRelations
  long[] MissedNodeIds
  long[] MissedWayIds
  long[] MissedRelationIds
}

Caching

Loading from the database takes significant time, for continents it can be hours. OsmDataKit allows you to cache the result of any request to a file. To do this, specify the argument cacheName.

OsmService.CacheDirectory = "osm-cache";

var geosByFilter = OsmService.LoadObjects(pathToPbf, cacheName: "geosByFilter", requestByFilter);
var geosByIds = OsmService.LoadObjects(pathToPbf, cacheName: "geosByIds", requestByIds);
var completeByFilter = OsmService.LoadCompleteObjects(pathToPbf, cacheName: "completeByFilter", requestByFilter);
var completeByIds = OsmService.LoadCompleteObjects(pathToPbf, cacheName: "completeByIds", requestByIds);

<br>

<a name="projects"></a>Projects

The OsmDataKit was designed for toponymic science projects — Toponim.by and Toponym.org. <br><br><br>

<a name="license"></a>License

The OsmDataKit is licensed under the MIT license. <br><br>

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.1 1,096 5/9/2022
3.1.0 925 4/27/2022
3.0.3 1,151 9/28/2020
3.0.2 1,059 3/28/2020
3.0.1 952 3/22/2020
3.0.0 1,033 3/21/2020
2.2.1 1,008 2/29/2020
2.2.0 1,153 5/18/2019
2.1.0 1,034 5/17/2019
2.0.0 1,105 5/13/2019
1.6.0 1,091 5/5/2019
1.5.0 1,284 8/17/2018