terra121 icon indicating copy to clipboard operation
terra121 copied to clipboard

Better Buildings from OSM

Open AidanLovelace opened this issue 4 years ago • 10 comments

What does it do?

This pull request adds more advanced buildings to Terra 1 to 1. Instead of lumping the edges of buildings in with all the rest of the edges, it creates Building objects based around polygons created from ways and multipolygon relations. The buildings are still organized by chunks. I also wrote a separate ICubicStructureGenerator because with some buildings being very tall, a populator does not work as it only runs on chunks at the surface.

Here, you can download a compiled jar to test it: terra121-0.1.zip

Screenshots

A random shopping center in Nashville, TN image image

An area in downtown Nashville, TN image image

Change Log (major stuff)

  • Added a new ICubicStructureGenerator class BuildingGenerator
  • Added new Building and Polygon classes that represent the data of a building in the dataset package
  • Option to select between building outlines, shells, or none at all.
  • Option to select material for buildings (includes some random options).
  • Added a couple methods to the OpenStreetMaps class to sort out the buildings from the rest
  • ~~Slightly modified RoadGenerator to avoid roads overwriting buildings~~ Went back on this change because of the ability for random materials. @taeko-chan
  • ~~Changed the OSM Building Outlines option text in all translations to just OSM Buildings.~~
  • Added a ConditionalShowElement (along with an accompanying function in EarthGui) to DynamicOptions to allow only showing an option if another option is a specific value.

Referenced Issues

#43 #28

Additional Notes

  • This system for multipolygons may be useful for the advanced water you've been working on since that's how most water is represented in OSM.
  • This system for polygons may be useful for things like parking lots or public squares where you have a large area to fill.
  • Buildings default to 2 "levels" with a level height of 4 meters if they don't have any tags indicating height or levels on OSM. (If a building only has a "building:levels" tag, it uses the default level height of 4 meters.)
  • An issue with the outlines was that as a builder for BTE it was difficult to "extrude" them upward because there was grass,etc in the way on non perfectly square buildings, so this feature even solves the problem of extruding the building outline upward by putting it above the surface.
  • Another issue with the outlines was the effort one had to put into clearing the terrain when the ground isn't perfectly level around a building.

AidanLovelace avatar May 04 '20 00:05 AidanLovelace

This is a really cool addition but can you get it working as an option. Theres a sub class in EarthGenetatorSettings and a list of statements in the gui class. Also be careful with the cutting out the bounding boxes those are there to restrict data useage. if you must then make sure it is only ignoring the bounding boxes for buildings and only when this mode is active.

orangeadam3 avatar May 04 '20 02:05 orangeadam3

this is really cool! I was thinking of doing something like this myself, but i never figured out a good way. i was wondering if you could tell me either here or on discord what you changed about the roads so i can ensure my generator for tunnels and bridges is compatible with this.

taeko-chan avatar May 04 '20 05:05 taeko-chan

This is a really cool addition but can you get it working as an option. Theres a sub class in EarthGenetatorSettings and a list of statements in the gui class. Also be careful with the cutting out the bounding boxes those are there to restrict data useage. if you must then make sure it is only ignoring the bounding boxes for buildings and only when this mode is active.

~~So you would rather have the option to chose between building outlines, building shells, and no buildings at all?~~ I've added the option to select between building outlines, building shells, and no buildings at all.

this is really cool! I was thinking of doing something like this myself, but i never figured out a good way. i was wondering if you could tell me either here or on discord what you changed about the roads so i can ensure my generator for tunnels and bridges is compatible with this.

In the placeEdge method of the RoadGenerator class, I added 2 checks in the loop that makes sure there's air above a road. Those 2 checks make sure the road will not replace parts of buildings with air.

AidanLovelace avatar May 04 '20 11:05 AidanLovelace

Now this is what i followed terra 121 for.

LittlePippy avatar May 06 '20 19:05 LittlePippy

Hey unsure if this is the correct place but how do i merge and complile pull requests for personal use

LittlePippy avatar May 06 '20 20:05 LittlePippy

Not the right place, but create a pull request from my BetterBuildings branch(or whereever a pull request is from) to your master branch(or whereever you want it).

AidanLovelace avatar May 06 '20 23:05 AidanLovelace

Alright. And for a suggestion, i think there's OSM tags for building Type. I think itd be nice to have buildings be "generated" based on what it is like if its a fastfood restaraunt it can generate a restaraunt build. Makes it more nicer to drive around places and less bland (Considering these buildings are just one material and mobs inside afterall).

Edit: The white house doesnt exist for some reason.

LittlePippy avatar May 07 '20 20:05 LittlePippy

I think itd be nice to have buildings be "generated" based on what it is like if its a fastfood restaraunt it can generate a restaraunt build.

That's outside the scope of this feature. You are correct that OSM has a tag to indicate type of building, but implementing that would be an incredible amount of work. One would have to build several variants of each of the possible entries for the amenity tag from OSM. https://wiki.openstreetmap.org/wiki/Key:amenity

On second thought, it's really outside the scope of the mod which is to generate the world as accurately as possible from datasets. Using pre-built buildings would defeat the purpose.

AidanLovelace avatar May 08 '20 19:05 AidanLovelace

@orangeadam3

Also be careful with the cutting out the bounding boxes those are there to restrict data useage. if you must then make sure it is only ignoring the bounding boxes for buildings and only when this mode is active.

I only removed the bounding box from the geometry output (positions of all the nodes of the included ways) because it would return null for all the nodes outside of the bounding box. This lead to the edge case where an edge (hehe get it? edge case) that crossed a region boundary may not generate correctly. Additionally, for creating building objects, the positions of all of the nodes for the buildings are needed to generate any of it.

If that resolves this specific issue, then I think I've got this feature merge-ready! :)

AidanLovelace avatar May 08 '20 19:05 AidanLovelace

Well I already done this but without following the OSM api I just made a compatible Lost Cities patch for T121: https://github.com/uta-org/LostCities-Patched

It would be great to merge the work into one patch or maybe a unique mod. The problem is that Lost Cities generates buildings following a preset, so it's not good at the task of generating builds from a given polygon which could be cool.

EDIT: I tested your version with CC 1049 and CWG 123 and it gave me a NullPointerException.

latest (2).log debug (2).log

z3nth10n avatar Oct 30 '20 01:10 z3nth10n