Comments (8)
You can first filter out only the ways you need, look at their nodes and keep a set of node ids you need. Then do a second pass and only keep the nodes you need.
from core.
Actually, I can't find a single item marked with OsmSharp.Type.Way
public void GetAllRoads()
{
var directory = $"{Directory.GetCurrentDirectory()}{@"\wwwroot\files\norway-latest.osm.pbf"}";
using (var fileStream = new FileInfo(directory).OpenRead())
{
var source = new PBFOsmStreamSource(fileStream);
var filtered = source.Where(x => x.Type == OsmSharp.OsmGeoType.Way);
var completes = filtered.ToFeatureSource();
var completesCount = completes.Count(); //0
}
}
from core.
I see that the source filter works as it should, it provides all roads in Norway; each item with a node list of type long (Which I assume are Node ID's?).
Is it ToFeatureSource that is not able to convert the nodes to a LineString for some reason?
from core.
What if you leave out the call to tofeaturesource?
from core.
What if you leave out the call to tofeaturesource?
That gives me a list of what I assume are node id's of type long, I thought ToFeatureSource was supposed to then find the nodes and make a LineString of them, with actual coordinates? This is probably what I'm doing wrong then.
Or am I meant to manually look up each node ID and extract the coordinates myself?
from core.
I'm using the net6.0 Framework, might that be an issue?
from core.
You should not filter out the Nodes here:
var filtered = source.Where(x => x.Type == OsmSharp.OsmGeoType.Way);
Perhaps this will work:
var filtered = source.Where(x => x.Type == OsmSharp.OsmGeoType.Way || x.Type == OsmSharp.OsmGeoType.Node );
The feature source needs the nodes to build the linestrings for the ways. Without the nodes it can't do anything.
You probably get 390 because by coincidence some nodes have a highway tag. The 168571 are all the nodes with a highway tag most likely plus the 390.
from core.
The feature source needs the nodes to build the linestrings for the ways. Without the nodes it can't do anything.
Ah, that makes total sense. Even obvious, now that you point it out.
The only problem I have with that is that it requires a huge amount of memory, is there a built in way for it to traverse the data without having to commit all the node data to memory? Basically exchanging speed for less memory usage?
from core.
Related Issues (20)
- Running into System.IO.EndOfStreamException HOT 6
- Join on filtering OSM data
- Complete Stream leads to data loss HOT 3
- Message=Method not found: 'ProtoBuf.Meta.RuntimeTypeModel ProtoBuf.Meta.TypeModel.Create() HOT 4
- DefaultFeatureInterpreter is broken
- Error when saving PBF with compression: block raw size expected
- OSM pbf read performance HOT 5
- May be a memory leak in PbfReader ? HOT 1
- How to fetch Latitude and Longitude co-ordinates from osmGeo object while filtering HOT 4
- Read OSM PBF file
- Get the id by latitude and logitude HOT 2
- Release official OsmSharp NuGet HOT 1
- Getting layers?
- PBF StreamSource to FeatureSource - 'Attribute id already exists!' when creating Feature list HOT 3
- Read OSM PBF file header and bounds? HOT 1
- Osrm can't parse created .osm.pbf files
- Osm file? HOT 1
- If a way or relation has an id attribute, an "Attribute id already exists" exception will throws. HOT 1
- SerializeToXml() throws an exception
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.