Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable reading of pbfs with node location for ways #110

Open
sergiupantiru opened this issue Jun 24, 2023 · 7 comments · May be fixed by #111
Open

enable reading of pbfs with node location for ways #110

sergiupantiru opened this issue Jun 24, 2023 · 7 comments · May be fixed by #111

Comments

@sergiupantiru
Copy link

Hello,

I've looked into adding lat/long support for Ways. I know that osmium can add location on ways and that some other tools can read it. This would allow you to create the WKT of the way without too much headache.

I've added the lat/lon, the same as the osmformat.proto

message Way {
   required int64 id = 1;
   // Parallel arrays.
   repeated uint32 keys = 2 [packed = true];
   repeated uint32 vals = 3 [packed = true];

   optional Info info = 4;

   repeated sint64 refs = 8 [packed = true];  // DELTA coded

+  repeated sint64 lat = 9 [packed = true]; // DELTA coded, optional
+  repeated sint64 lon = 10 [packed = true]; // DELTA coded, optional
}

In the OsmSqlEtity I've added a new schema for way.nodes

  lazy val wayNodeSchema = StructType(
    Seq(
      StructField(FIELD_ID, LongType, true),
      StructField(FIELD_LATITUDE, DoubleType, true),
      StructField(FIELD_LONGITUDE, DoubleType, true)
    ))

Before I make a PR I wanted to know your opinion if this would be acceptable.

Thanks in advance

@sergiupantiru sergiupantiru changed the title allow to read pbf with node location for ways enable reading of pbfs with node location for ways Jun 24, 2023
@angelcervera
Copy link
Member

Do you know if they are used in any of the official pbf files? If that is the case, it is fine to add it, but I'm pretty sure that it will be necessary to add more code to read and manage it properly (ex. They are deltas, so it's necessary to calculate the real value).

FYI: @angelcerveraroldan

@sergiupantiru
Copy link
Author

I don't think there are official pbfs that already have geometry, but with osmium you can add it. The lat/lon is present in the pbf format https://wiki.openstreetmap.org/wiki/PBF_Format.

I do have more code on a branch, and will ask for a PR.

@angelcervera
Copy link
Member

Feel free to create the PR. Could you find a small pbf with this data as example and add it into the testing?

@sergiupantiru
Copy link
Author

I've added Monaco with geometry and added some test cases

@angelcervera
Copy link
Member

Forget what I said about Feroe Islands. Monaco is the one used for testing, so good.
BTW, be careful to don't add data about users in the repo. monaco-anonymized.osm.pbf is monaco without history to avoid to add personal info.

@sergiupantiru
Copy link
Author

Forget what I said about Feroe Islands. Monaco is the one used for testing, so good.

BTW, be careful to don't add data about users in the repo. monaco-anonymized.osm.pbf is monaco without history to avoid to add personal info.

I just added way node location on the Monaco file from the repo. Should be exactly the same + lay/long

@angelcervera
Copy link
Member

@sergiupantiru Thanks for the PR. Give me few days to find free time to do the code review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants