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

Getting the width of a street section from a PML file #67

Open
vvoovv opened this issue Nov 18, 2023 · 8 comments
Open

Getting the width of a street section from a PML file #67

vvoovv opened this issue Nov 18, 2023 · 8 comments

Comments

@vvoovv
Copy link
Member

vvoovv commented Nov 18, 2023

I'd like to define widths of street sections and other attributes in a PML file.

A PML style is chosen based on the category of an OSM way, the number of lanes, etc.

If possible, an instance of the class StreetSection should be created earlier in the code. A renderer exposes a method getStyle which accepts tags as a parameter and returns a style defined in PML. The attributes of the instance of the class StreetSection (width, the number lanes) are set in accordance with the values in the PML style.

How easy would it be to refactor the existing code?

@polarkernel
Copy link
Collaborator

How easy would it be to refactor the existing code?

I don't think this is too complicated. The instances of StreetSection are constructed at the end of the StreetGenerator processes. Before that, an internal and complicated class WaySection, defined in way/way_section.py is used. Its constructor creates it from the section network in the StreetGenerator's createWaySections() function. This is also where the way widths are set, based on the wayCategoryProps in way_properties.py, by calling estimateWayWidths(). The lane patterns for the turn lanes are also set here.

In createWaySections(), the method getStyle could be called, and their returned parameters could replace the default ones in WaySection.

@vvoovv
Copy link
Member Author

vvoovv commented Nov 20, 2023

What is the difference between the classes NetSection, WaySection and StreetSection?

@polarkernel
Copy link
Collaborator

polarkernel commented Nov 20, 2023

What is the difference between the classes NetSection, WaySection and StreetSection?

Well, the NetSection class holds the edges in the instances (networkGraph, sectionNetwork) of the WayNetwork class. It is only related to the networks.

The WaySection class is the working horse of way processing. Unlike the instances of NetSection, there is only one (directed) instance per way section. Its polyline is represented by an instance of the PolyLine class, which provides powerful methods for parametrization, the calculation of intersections, trimming, distances, projections, offset lines, and so on. WaySection is also used to keep track of lanes and their widths.

Finally, the class StreetSection (formerly TrimmedWaySection) is used as the output class. Classes internal to street generation (for instance PolyLine) are omitted, so that only Python classes or Blender classes are used there.

@vvoovv
Copy link
Member Author

vvoovv commented Nov 20, 2023

What would be the obstacles to merge WaySection and StreetSection into a single class?

@polarkernel
Copy link
Collaborator

What would be the obstacles to merge WaySection and StreetSection into a single class?

The main differences I see are

  • Not all sections in the WaySections dictionary are valid. Some have been invalidated because they were too short or were covered by clusters or for other reasons. If we used WaySections instead of StreetSections, the renderer would have to test for isValid on each instance.
  • The polyline of the WaySection keeps the original length of the section as given by the OSM data. The shorter trimmed centerline, e.g. truncated by intersections, must be calculated and stored anyway.
  • The keys of the WaySection dictionary are different from the keys of the _StreetSection_s dictionary, but I can't say yet if this would be a problem.
  • The lane data in StreetSections is different in details from that in WaySections. StreetSections would require its own attributes.

@vvoovv
Copy link
Member Author

vvoovv commented Nov 20, 2023

I suggest gradually merging WaySection and StreetSection. But first I'd like to integrate reading PML attributes in the method createWaySections() of the class StreetGenerator.

@polarkernel
Copy link
Collaborator

I suggest gradually merging WaySection and StreetSection.

OK. Just out of curiosity: What's the benefit of that?

@vvoovv
Copy link
Member Author

vvoovv commented Nov 21, 2023

OK. Just out of curiosity: What's the benefit of that?

No need to create an additional structure.

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

No branches or pull requests

2 participants