Coder Social home page Coder Social logo

core's Introduction

OsmSharp

This repository is not maintained anymore. Check osmsharp.com for more info.

From the website:

OsmSharp used to do everything on top of what it does today, including routing and rendering geo data. This was too much and the name OsmSharp didn’t make sense anymore. Now the old functionality has been replaced by several seperate projects:

  • OsmSharp: Working with OSM-data, filtering, transforming.
  • Itinero: The routing project is now maintained under the name Itinero.
  • UI: This UI and rendering project has not been replaced. Instead we recommend using Mapsui.

core's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

core's Issues

Issues with released version 6.0?

I'm seeing a very strange behavior - I'm migrating my project from .net core 1.1 to 2.0.
Since I'm upgrading infra I though I should move out of the prereleased versions to 6.0.
When I did that the following code stopped working as expected:

var source = new PBFOsmStreamSource(osmFileStream);
                var completeSource = new OsmSimpleCompleteStreamSource(source);
                var namesDictionary = completeSource
                    .Where(o => string.IsNullOrWhiteSpace(o.Tags.GetName()) == false)
                    .GroupBy(o => o.Tags.GetName())
                    .ToDictionary(g => g.Key, g => g.ToList());

It started to return an empty dictionary and it seems like it doesn't scan the pbf file (osmFileStream is a stream to a pbf file).
Are you aware of this issue?
I have reverted back to pre08 and it started working again...

Release OsmSharp NuGet

I believe it's time to do an official release instead of pre-release, don't you think? :-)

Implement complete PBF write support

Implement full PBF write support. OsmSharp only supports a simple (but compatible) version of the OSM PBF format. This leads to bigger files than expected.

Do not expose Ionic.Zip types such as DeflateStream

The NuGet package for OsmSharp.dll version 5.0.8.0 accidentally exposes some types such as DeflateStream. This causes compiler errors because the type name and namespace are identical to commonly used BCL types. Those types should be included privately.

image

Geocoding

How can I make a request to get lat:lon from a given country/state/address? (geocoding). I have a pbf file (and I have the file inside a SQL DB).

Ping

Hi Ben, is everything ok? Can you pls contact me? Was sending you several emails the past weeks but it seems that you didn't get them or I didn't receive your answer, for what ever reason. Thanks Tom

OsmSharp with Xamarin (Forms)

Hi.

Is it possible to use OsmSharp with Xamarin or Xamarin Forms?
I've tried to use the nuget version 5.0.8 from nuget PM but it doesn't go well and it's conflicting in my VS 2017 Xamarin Forms solution when I try to run it in Xamarin.Droid.

The mscorlib.dll is doubled up by MonoAndroid and the new installed dependency "Microsoft.NETCore.Portable.Compatibility (1.0.1)"

Problem with deserialization of OSM object

Not sure if this is related to the fact that I'm using the alpha version or not but after the Osm class change the following test fails:

    [TestClass]
    public class OsmSerialization
    {
        [TestMethod]
        public void TestDeserializationOfUserDetailsResponse()
        {
            var resonseString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm version=\"0.6\" generator=\"OpenStreetMap server\">\n  <user id=\"111\" display_name=\"Test\" account_created=\"2013-03-09T17:55:56Z\">\n    <description></description>\n    <contributor-terms agreed=\"true\" pd=\"false\"/>\n    <img href=\"http://www.gravatar.com/avatar/not-a-real-one.jpg?s=256&amp;d=http%3A%2F%2Fwww.openstreetmap.org%2Fassets%2Fusers%2Fimages%2Flarge-afe7442b856c223cca92b1a16d96a3266ec0c86cac8031269e90ef93562adb72.png\"/>\n    <roles>\n    </roles>\n    <changesets count=\"226\"/>\n    <traces count=\"27\"/>\n    <blocks>\n      <received count=\"0\" active=\"0\"/>\n    </blocks>\n    <home lat=\"30.0\" lon=\"30.0\" zoom=\"3\"/>\n    <languages>\n      <lang>he</lang>\n      <lang>en-US</lang>\n      <lang>en</lang>\n    </languages>\n    <messages>\n      <received count=\"14\" unread=\"0\"/>\n      <sent count=\"9\"/>\n    </messages>\n  </user>\n</osm>\n";
            var stream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(resonseString));
            var serializer = new XmlSerializer(typeof(Osm));
            var osm = serializer.Deserialize(stream) as Osm;
            Assert.IsNotNull(osm.User);
        }
    }

This is a (modified for privacy reasons) string of the response I'm getting from the Osm Api server.

GeoJson Feature object throws exception when try to serialize it to json string

I'm trying to convent an OsmComplete object to geojson OsmSharp.GeoFeatures.Feature.
I have a working code that does the conversion, but when I want to serialize it I'm getting an exception:
The method or operation is not implemented.
I'm using newton json:

JsonConvert.SerializeObject(geojson)

I've been using GeoJson.Net which I find follows all the geojson guidelines. I suggest to use it in this project as well. :-)

Create docs on some of the basics

Create docs on some of the basics:

  • Streaming data from an osm.pbf file.
  • Filter data from a source stream.
  • Convert to 'complete' objects.
  • Convert to geometries.

Element latitude/longitude are private

Hi,

Going through the elements in my source file like this:

using (var fileStream = new FileInfo("C://Temp//OpenStreetMap//berlin_germany.osm.pbf").OpenRead())
{
	int counter = 0;

	var source = new PBFOsmStreamSource(fileStream);

	foreach (var element in source)
	{
		// element.Latitude; // private
		// element.Longitude; // private

		textBox1.Text += element.ToString() + Environment.NewLine;

		counter++;
		if (counter >= 10)
			break;
	}
}

I would love to also get the latitude/longitude for each element, but for some reason these two variables are private.

Can you share a secret trick to access latitude/longitude for each element in a stream?

Thanks!

Exsample project don't build in visual studio 2015

I have downloaded zip from github site and unzipped it. Then I double click on OsmSharp.sln and my VS2015 says "One or more projects in the solution were not loaded correctly. Please see the Output Window for details."

We were unable to automatically populate your Visual Studio Team Services accounts.
The following error was encountered: TF400813: Resource not available for anonymous access. Client authentication required.

How to fix this?

System.NullReferenceException from small XML-file

Hello,

I get a NULL-error when trying to parse a small XML-file of my neighborhood
downloaded from Openstreetmap.org

To reproduce:

  1. Download the XML from http://www.openstreetmap.org/export#map=17/59.92790/10.79067
    This 1,2MB file can be taken directly from the above link or downloaded from here: https://www.dropbox.com/s/s74wcptofcnl5sy/loren_final.zip?dl=0

  2. The following code was used (more or less directly taken from the samples) to count the number of linestringpolygons:


static void minimalexample()
{
    var source = new XmlOsmStreamSource(File.OpenRead("loren_final.osm"));
    var filtered = from osmGeo in source select osmGeo;
    var features = filtered.ToFeatureSource();
    var lineStrings = from feature in features
                        where feature.Geometry is LineString
                        select feature;
    Console.WriteLine(lineStrings.Count().ToString());
}
  1. The same happens if i convert it to .PBF
  2. I have been trying with both 5.0.7 and 6.0.0prealpha
  3. The exact error given is
    Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
    at OsmSharp.Geo.DefaultFeatureInterpreter.Interpret(ICompleteOsmGeo osmObject)
    at OsmSharp.Geo.Streams.Features.Interpreted.InterpretedFeatureStreamSource.MoveNext()
    at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.Count[TSource](IEnumerable1 source)

BR,
Erik

Out of memory exception when using OsmSimpleCompleteStreamSource

Hi,
I'm trying to use the complete stream source on a relatively large data (Entire Isreal)
http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf
The following is the exception:

at OsmSharp.Osm.PBF.Streams.PBFOsmStreamSource.MoveNext(Boolean ignoreNodes, Boolean ignoreWays, Boolean ignoreRelations)
 at OsmSharp.Osm.Streams.Complete.OsmSimpleCompleteStreamSource.MoveNext()
 at IsraelHiking.API.Services.OsmDataService.<UpdateElasticSearchFromFile>d__11.MoveNext() in D:\Github\IsraelHikingMap\Site\IsraelHiking.API\Services\OsmDataService.cs:line 82

I'm using a machine with 16Gb RAM.
I tried to use it without the complete stream and I think it didn't had this exception, but then I needed to cache the data into dictionaries and I think the issue was there when the dictionaries got too big.
the code I'm writing is something like so:

            var source = new PBFOsmStreamSource(stream);
            await _elasticSearchGateway.DeleteAll();
            var completeSource = new OsmSimpleCompleteStreamSource(source);
            var converter = new OsmGeoJsonConverter();
            var list = new List<Feature>(PAGE_SIZE);
            int page = 0;
            foreach (var completeOsmGeo in completeSource)
            {
                var geoJson = converter.ToGeoJson(completeOsmGeo);
                if (geoJson?.Properties == null || !geoJson.Properties.Keys.Any(k => k.Contains("name")))
                {
                    continue;
                }
                list.Add(geoJson);
                if (list.Count == PAGE_SIZE)
                {
                    page++;
                    _logger.Info($"Indexing {PAGE_SIZE * page} records");
                    _elasticSearchGateway.UpdateData(list).Wait();
                    list.Clear();
                }
            }

basically what it does is convert the osm to geojson and index in bulks in elastic search.
Any advise?

Add support for gpx_file in OSM v0.6 API classes

I want to update Osm trace using the OSM API and OSM Sharp or to get a trace data.
The following is the response that is returned from an API call:
API address:
https://www.openstreetmap.org/api/0.6/gpx/2463219
Response:

<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<gpx_file id="2463219" name="20170726.gpx" lat="42.6896" lon="-84.4321" user="jojkuhiuwer" visibility="identifiable" pending="false" timestamp="2017-07-26T21:04:01Z">
<description>NU3001</description>
<tag>GPSLogger</tag>
</gpx_file>
</osm>

I'm not sure, but I don't see that this type of response is defined in the Osm class, right?
image

Error when try to install nuget package

Hello, I can't install OsmSharp library and link with Xamarin.Android project. The problem with some OsmSharp's dependency. Please, help me!

Error message:

Could not install package 'Microsoft.NETCore.Jit 1.0.2'. You are trying to install this package into a project that targets
'MonoAndroid,Version=v8.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more
information, contact the package author

Call for feedback

If there is anyone that is still having issues with the latest prerelease version please let us know here. cc @HarelM

If no new issue are reported I will be releasing 6.0 by the first of June (5 days from posting this).

DiffResult is not parsed correctly

The following test fails (diffResult.Results == null):

        [TestMethod]
        public void TestXmlDiffDeserialize()
        {
            var str = @"<?xml version='1.0' encoding='UTF-8'?>
<diffResult version='0.6' generator='OpenStreetMap server' copyright='OpenStreetMap and contributors' attribution='http://www.openstreetmap.org/copyright' license='http://opendatacommons.org/licenses/odbl/1-0/'>
  <node old_id='-1' new_id='5568804727' new_version='1'/>
  <way old_id='-2' new_id='582221647' new_version='1'/>
  <way old_id='481193304' new_id='481193304' new_version='2'/>
</diffResult>";
            XmlSerializer ser = new XmlSerializer(typeof(DiffResult));
            var diffResult = ser.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(str))) as DiffResult;
            Assert.IsNotNull(diffResult);
            Assert.AreEqual(3, diffResult.Results.Length);
        }

I'll see if I can look at the code and identify the bug.
The problem is that I can't updated OSM due to issue #49.
Please let me know if this is something you can take care of so that I'll be able to use the latest version of OsmSharp.Core along with this fix.

Missing etensionType in gpx class

Since I'm using OSM Sharp in my project and I have the gpx xsd I wanted to remove it from my code assuming I can use OsmSharp.IO.Xml.Gpx.v1_1.
Unfortunately I couldn't find extensionsType in the above namespace.
Am I missing something?
xsd can be found here:
https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.API/Gpx/GpxTypes.xsd
cs generated file can be found here:
https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.API/Gpx/GpxTypes.cs

Incompatibility with geofabrik extracts, as of may 03 '18

It looks like geofabrik.de has implemented the new EU Law - General Data Protection Regulation (GDPR).
ref: https://en.wikipedia.org/wiki/General_Data_Protection_Regulation

Announcement on geofabrik:

The OpenStreetMap data files provided on this server do not contain the user names, user IDs and changeset IDs of the OSM objects. These metadata fields contain personal information about the OpenStreetMap contributors and are subject to data protection regulations in the European Union. Please note that these regulations apply even to processing that happens outside the European Union because some OpenStreetMap contributors live in the European Union.

The issue occurs when data is tried to be extracted to a list:

var source = new PBFOsmStreamSource(fileStream);
var filteredQuery = from osmGeo in source where
                         osmGeo.Type == OsmGeoType.Way &&
                         osmGeo.Tags.ContainsKey("highway") &&
                         !osmGeo.Tags.Contains("highway", "cycleway") &&
                         !osmGeo.Tags.Contains("highway", "bus_stop") &&
                         !osmGeo.Tags.Contains("highway", "street_lamp") &&
                         !osmGeo.Tags.Contains("highway", "path") &&
                         !osmGeo.Tags.Contains("highway", "turning_cycle") &&
                         !osmGeo.Tags.Contains("highway", "traffic_signals") &&
                         !osmGeo.Tags.Contains("highway", "stops") &&
                         !osmGeo.Tags.Contains("highway", "pedestrian") &&
                         !osmGeo.Tags.Contains("highway", "footway") || 
                         osmGeo.Type == OsmGeoType.Node
                    select osmGeo;

var collectionComplete = filteredQuery.ToComplete();
var ways = collectionComplete.Where(x => x.Type == OsmGeoType.Way).ToList(); //<-- Error occurs with the new *-latest.osm.obf files as of May 3rd. 

previous -osm.pbf files, containing the user names, user IDs and changeset IDs of the OSM objects, are processed without any errors.

Missing fields in ICompleteOsmGeo

The interface ICompleteOsmGeo is a great way to bring together OsmGeo and OsmCompleteGeo.
I wanted to extract out of it what both implementation have which is UserName and TimeStamp since I want to present in my site the last person who contributed to a specific point.
See here:
IsraelHikingMap/Site#730
When trying to extract this data from an OSM element I noticed I need to down cast to one of the abstract derivatives.
I think it would be correct to add to ICompleteOsmGeo the above two fields:
UserName and TimeStamp
Let me know what you think.

ToSimple method is missing?

Hi, I stated a migration to .Net Core and I'm using the alpha version, but there is a method that I'm using in order to update the OSM database called ToSimple() which is no longer supported in latest release.
Is there a change to bring it back?
Use case scenario:

  1. Get complete way from OSM
  2. test stuff against this full way
  3. add a point to that way
  4. update way in OSM.

By the way, great change in OSM API and regular POCOs!
Thanks, Keep up the good work!

Documentation is extremely partial

Hi,

I'm trying to build a Nominatim-Photon like search engine for my project.
I'm very much interested in this project as I see the potential in it and will also be happy to help out if needed.
Unfortunately I'm unable to understand how to operate all this - the documentation is very partial
What's I'm currently trying to achieve is the following:

  1. read an pbf file.
  2. iterate through all the nodes ways and relations and index them into an elastic search database.
  3. Add a controller to my WebApi in order to facilitate the search.

The project Israel Hiking is open source and runs on IIS on a windows server.

geocoding

hi everybody,
great work, this library seems fantastic.
I've only a question: how can I manage a geocoding feature? My need is to resolve a coordinate (Lat Lon) with the corresponding street in a fast manner.
Is it possible?
Thanks in advance!

Nicola

Seperate out memory mapping

This project contains cross-platform memory mapping functionality. Seperate this into another project because it has much wider usage.

LinearRing creating failed when the number of coordinates equals 3 in DefaultFeatureInterpreter

I'm using OsmSharp in one project and trying to extract FeatureSource from .osm files (similar to the GeometryStream sample). In some cases I have got the following exception when running the ToFeatureSource() method:

System.ArgumentException: Number of points must be 0 or >3
  at NetTopologySuite.Geometries.LinearRing.ValidateConstruction () [0x00037] in <88415ec09cd24df3957abfca9e43fb89>:0 
  at NetTopologySuite.Geometries.LinearRing..ctor (GeoAPI.Geometries.ICoordinateSequence points, GeoAPI.Geometries.IGeometryFactory factory) [0x00008] in <88415ec09cd24df3957abfca9e43fb89>:0 
  at NetTopologySuite.Geometries.LinearRing..ctor (GeoAPI.Geometries.Coordinate[] points) [0x00011] in <88415ec09cd24df3957abfca9e43fb89>:0 
  at OsmSharp.Geo.DefaultFeatureInterpreter.Interpret (OsmSharp.Complete.ICompleteOsmGeo osmObject) [0x00401] in D:\Projects\OsmSharp\core\src\OsmSharp.Geo\DefaultFeatureInterpreter.cs:129 
  at OsmSharp.Geo.Streams.Features.Interpreted.InterpretedFeatureStreamSource.MoveNext () [0x0005e] in D:\Projects\OsmSharp\core\src\OsmSharp.Geo\Streams\Features\Interpreted\InterpretedFeatureStreamSource.cs:163 

When I checked the constructor of LinearRing (code here), I found that LinearRing had set a limit of at least 4 points to create a ring. However, the code in DefaultFeatureInterpreter only checks whether the number of coordinates is less than 3, which causes this exception.

If this is a bug, please help fix this problem. Thank you.

Communicate about trust in sorted data

Most source streams are sorted and some filters use this knowledge, we need to have a filter communicate to a source that they count on a sorted stream and then to have things fail when that doesn't turn out to be the case.

missing lat and lon

Sorry of this is the wrong way to ask but I could see a better way. I am working with this and have a problem. I am parsing through a large pbs file and want to loop through certain nodes/ways but I need to be able to get the lat and lon from the "element" but I cant see it, code below. Problem is that OSMGEO doesnt know about those attributes so how can I get them?

namespace OsmSharp
{
public abstract class OsmGeo
{
protected OsmGeo();

    public long? Id { get; set; }
    public OsmGeoType Type { get; protected set; }
    public TagsCollectionBase Tags { get; set; }
    public long? ChangeSetId { get; set; }
    public bool? Visible { get; set; }
    public DateTime? TimeStamp { get; set; }
    public int? Version { get; set; }
    public long? UserId { get; set; }
    public string UserName { get; set; }
}

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using OsmSharp;
using OsmSharp.Changesets;
using OsmSharp.Complete;
using OsmSharp.IO.PBF;
using OsmSharp.IO.Xml;
using OsmSharp.Logging;
using OsmSharp.Streams;

namespace readosmdata
{
class Program
{
static void Main(string[] args)
{
using (var fileStream = new FileInfo(@"D:/Users/Johan/MyDocuments/Projects/readosmdata/europe-latest.osm.pbf").OpenRead())
{
var source = new PBFOsmStreamSource(fileStream);

            Console.WriteLine(DateTime.Now);


            var filtered = from osmGeo in source
                where osmGeo.Type == OsmGeoType.Node ||
                      (osmGeo.Type == OsmGeoType.Way && osmGeo.Tags != null && osmGeo.Tags.Contains("power", "line"))
                select osmGeo;

            var complete = filtered.ToComplete();

            foreach (OsmGeo element in complete)
            {

                        foreach (var subTag in element.Tags)
                        {
                            if (subTag.Key.ToLower().Equals("building") || subTag.Key.ToLower().Equals("highway") ||
                                subTag.Key.ToLower().Equals("footpath") || subTag.Key.ToLower().Equals("power"))
                            {
                                Console.WriteLine(subTag.Key + " = " + subTag.Value);
                            }
                        }

                        //Console.WriteLine(element.ToString());
               }

            Console.WriteLine(DateTime.Now);
        }
    }
}

}

Add OSM ids and tags to generated features.

I try extract list of object (for example all school from specified country) from PBF file. Except basic data I need polygon and centroid of polygon. I found that polygon is posible to get after convert source to feature source. But I don't know how get both - polygon from feature source and basic data from source. Any ideas?

Relations in Complete: best effort strategy.

Hi!
Say, I need to get country boundaries. So, I tried:

var filtered = from osmGeo in source where osmGeo.Type == OsmSharp.OsmGeoType.Node || osmGeo.Type == OsmSharp.OsmGeoType.Way || (osmGeo.Type == OsmSharp.OsmGeoType.Relation && osmGeo.Tags != null && osmGeo.Tags.Contains("admin_level", "2") && osmGeo.Tags.Contains("type", "boundary")) select osmGeo;

Now, the result contains nodes, ways and relations (3 in case of Andorra),

But when I attempt to make complete objects, relations vanish:

var completeRelations = filtered.ToComplete().Where(x => x.Type == OsmSharp.OsmGeoType.Relation).ToList();
returns an empty results. The Ways seem to be processed well, btw, but relations are gone.

Any idea, why?
Thanks a lot

Tomas.

Fix links in readme.

Fix links in readme, there is some stuff broken there related to the nuget packages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.