0.7.3: Bug fixes, GeoJSON export
Medieval Fantasy City Generator » Devlog
- The main point of this update is to fix an ugly bug which occasionally caused a pretty serious computer freeze. I can't be 100% sure that exactly that bug is fixed, but I've found (and fixed) a couple of errors which could be the reason of the issue.
- A number of smaller bugs were fixed including the one with extramural buildings being placed too close to the city wall, the one with both ends of the river on the coast, the one with weird roads etc. The actual list is quite long.
- To prevent gates from overlapping neighbouring buildings, small plazas are now created around gates.
- I have finally replaced my naive implementation of Bowyer-Watson algorithm with a port of Delaunator for creating Voronoi diagrams. What does it mean on practice? It means that one of the stages of city generation is now a hundred times faster. This stage wasn't a bottle neck, so you probably won't see a difference, but it's important for further development of the generator.
- Export to JSON (to GeoJSON to be exact) is added for those who want to tinker with data created by MFCG, instead of images. This is not the final version of this feature, I'm not even sure I want to stick with GeoJSON (it seems kind of awkward to me), so your feedback is most welcome.
- Two new URL parameters added: gates & export. The former lets you specify the exact number of gates (for example, gates=0 will produce a city without gates). The latter (with valid values of png, svg and json) makes the generator export the map right after creating it. It can be useful for some kind of automation.
Medieval Fantasy City Generator
Not a game
Status | In development |
Category | Tool |
Author | watabou |
Tags | City Builder, Fantasy, Medieval, Procedural Generation |
Languages | English |
Accessibility | Color-blind friendly, High-contrast |
More posts
- 0.11.2: small improvements and bug fixes60 days ago
- 0.11.1: improved map labelsApr 15, 2024
- 0.11.0: roof details and district viewApr 08, 2024
- 0.10.2: alleys viewMar 16, 2024
- 0.10.1Feb 21, 2024
- 0.10.0-alphaAug 18, 2023
- Keyboard shortcuts and mouse actionsFeb 25, 2023
- 0.9.2: assorted new features and improvementsFeb 24, 2023
- 0.9.1: trees and other visual changesFeb 09, 2022
- 0.9.0: new alleys and buildingsJan 11, 2022
Comments
Log in with itch.io to leave a comment.
I just noticed that the GeoJSON export doesn't include the wall's towers or gatehouses, apparently - or am I missing something?
That's correct. Towers are not shapes, they are vertices of the wall polygon. If such vertex is also a point of a road polyline, then it's a gatehouse.
Would it be much work to include them in the GeoJSON? So as to not repeat a calculation step and do tangent calculation?
The GeoJSON export is a pretty exciting. Haven't looked at the
GeoJSON spec yet but it seems weird to have the bldg coords in an array of arrays with those having a single element that is an array of arrays. Expected the coordinates themselves to be in a JSON object like {"x":0.05; "y":0.03}. But maybe that's the spec.
Also, are the coordinates in unit space? i.e. -1 to +1, x & y, in the "world" plane? Probably an RTFM for the spec question.
Anyway, looking forward to experimenting with bringing the JSON into a VTT and seeing about drawing the city dynamically instead of importing a static image.
The array is the GeoJSON format, that's correct. It doesn't use objects there.
The unts are world units. If you import it into GIS, you get a proper scale on your map.
I think I know what you mean by awkward. You export all buildings as one object. That's not how GeoJSON works. The MultiPolygon should be split up, one polygon per building. MultiPolygon can be used for a city gate, which has two towers but they're part of the same building really.
There's also something wrong in the MultiPolygon that I can't quite figure out, but QGIS is unable to split it into single parts, which it should be able to do.
Nevertheless, it's a huge step forward, already better results than the svg2json script I wrote for myself.
That was my intention, but apparently there is an error with the way I create multipolygons. As a result, instead of multiple polygons each consisting of a single "ring" (there are no buildings with holes) I create a single polygon consisting of multiple "rings". Too many nested arrays...
Yes, that's what it looks like. I would do one polygon per building. It also makes debugging and editing a LOT easier.
Fixed.
Brilliant! It works now, QGIS can split the multipart into single parts. I can now add the 400 city maps to my game world. :)
(here's what my own conversion script managed: https://notveryprofessional.com/dragoneye/atlas/Phonas -- you'll see the problems in the town wall, for example).
Question: Do you export parks as well?
I don't see problems with the walls, they look good imo :)
No, I don't export parks atm. Partly because I wanted to keep everything as simple as possible, but also because I haven't figured out yet what is the "best" way to encode some data. Parks don't have their own geometry, they are just wards marked as parks, but I don't export ward data so...
Why not export the ward data? Just as polygons with a "type" field that says "building zone" or "park"? That would be INCREDIBLY useful for zooming in, where at distance only the wards are visible and then they fade into individual buildings as you zoom in, the way Google maps does it. And you could export the ward names that way as well.
Absolutely fantastic! Please do keep the GeoJSON. It seems awkward but is by far the most useful format with the most options to convert into other formats.
I cannot see where to specify gate no, and when I add it into the parameters at the http level, it just reverts to no gate options - can you consider fixing this please, especially on the Style part of the menu.
Here is an example:
http://fantasycities.watabou.ru/?size=15&seed=1279697557&hub=0&random=0&citadel=1&plaza=1&temple=1&walls=1&shantytown=0&river=0&coast=0&gates=0
This should produce a walled city without gates (gates=0 in the end). After "submitting" a url the gates parameter is removed from the url - it's the intended behaviour.
Thank you. However, can this also be added to the Options part of the menu?
I use GeoJSON with LeafletJS to overlay geometry on top of images (using a non-globe project). I wasn't happy with it either, but it works well enough, people write plugins to manipulate it in useful ways, so it's not all bad. It could be useful to add an offset and a scale when exporting to GeoJSON, so people can add it to existing maps.
What do you mean by adding an offset and a scale? Right now all coordinate values are around zero, that's how they are generated. The scale is close to one I display in the generator.
If someone wanted to generate multiple cities to place them all on a larger map, they would want to adjust the coordinates to match their larger map. The larger map is going to have it's own coordinate system. Normally i think it would use Latitude and Longitude. The map I have uses pixels x,y of the most zoomed out image.
If was going to do it, I would write a script to import the city JSON and adjust things, someone else may just want to concatinate all the cities in one JSON file and use it like that.
Also exporting with coordinates in meters could be useful.
Ah! So you are talking about ability to specify a scale and an offset somewhere in the generator to get absolute coordinates in json, right? Well, if someone can parse GeoJSON (manually, using a tool or a library), I'm sure they can adjust coordinates as it fits their needs :)
It's relatively easy to do, though of course an option to do it at export time would be more comfortable. I'll see if I can make a short script the next days.
The maps this make looks so freakin real.
I still cannot work on it on Chrome :(
I use Chrome, and have no problem (except with the new gates parameter.
Do we need any settings to make it work??
There are two types of issues:
Please check this link. Does it work?
im using chrome same as OP here. that link does work, i can see the city but the original generator does not work. i just tried it on internet explorer but its doesnt work there either, probably not a browser thing?