Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

GeoJson export for Unity3D integration

A topic by InsaneQA created 19 days ago Views: 212 Replies: 3
Viewing posts 1 to 3

Hi!

I've started creating a 2D medieval game in Unity, and I must say that the Medieval Fantasy City Generator is totally superb, especially with the GeoJson export available!

However, it seems there is a bug in every exported json (please see the image below. I've used http://geojson.io/ for validation):

Basically, the first and the last points in the array should be the same. With this bug, the FeatureCollection object cannot be correctly deserialized. It can only be reproduced for buildings (not earth or walls).

 watabou, could you please fix the bug if that's not too timeconsuming?

I've fixed the bug manually for 2 documents (it took about 15-20 minutes), and here is the result of the mesh generation:

That's the first day of work with the GeoJson, so there are some buildings with the wrong shape, and the city is mirrowed, however it seems I'm on the right track.

I'm going to share the deserialization tool for Unity after it's done.

A small update: I've added a script to fix the Json problem. The script will also remove any ring with 3 points or less, since it's not allowed by the GeoJson specification.

Developer

Hi!

It doesn't conform to specification, but I wouldn't like to change this behavior.  Serializing the same point two times is obviously excessive for polygons. Of course, it's not much work to implement this serialization, but it seems to me that in most cases you'll need to discard that additional point after deserialization anyway.  And if you are writing your own importer (rather than using some strict existing one) it shouldn't be a problem, should it?

I said that I wouldn't like to change it, but it doesn't mean that I won't. This whole GeoJSON thing is work in progress, so how it will end up working depends on users feedback and my own experience with it. Any notes, suggestions and arguments are welcome!

(+1)

Sure, no need to worry - I've already handled the missing points in the code. 

There is also a situation when a building is imported with only 3 points and the last point equals to the first point (it's basically a line). I simply remove those buildings as well in the importer. 

Thanks!