osmlove library (OSM maps in your Love2D projects)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

osmlove library (OSM maps in your Love2D projects)

Post by dusoft »

Hi,

I have created a library that allows you to use geoJSON file (OSM XML to be implemented soon) and draw a map based on this.

Currently, only roads/streets/sidewalks/bridges (OSM type 'highways') are supported, but implementation of others is easy and will be coming. Custom rules can be defined regarding what to draw, what colors to use and parameters passed to draw only selected region based on lat/long coordinates or zoom to be used etc.

You can use it for backgrounds or e.g. drawing a map somewhere as a part of the game - picture on a wall, map on a table etc.

I am resolving some issues with the canvas caching, once it's ready, I'll publish it to github and link it here.

Screenshot of simplified map (b&w only, basic rules defined):
osmlove bratislava, zoom 2 (half city)
osmlove bratislava, zoom 2 (half city)
osmlove.png (289.31 KiB) Viewed 8148 times
osmlove addis ababa, zoom 1 (whole city)
osmlove addis ababa, zoom 1 (whole city)
osmlove2.png (377.9 KiB) Viewed 8143 times
User avatar
mtdev
Prole
Posts: 20
Joined: Mon Feb 20, 2017 5:10 am
Location: Midwest US

Re: osmlove library (OSM maps in your Love2D projects)

Post by mtdev »

Cool! Looking forward to seeing where this goes.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: osmlove library (OSM maps in your Love2D projects)

Post by zorg »

dusoft wrote: Sun Apr 02, 2017 7:04 pm You can use it for backgrounds or e.g. drawing a map somewhere as a part of the game - picture on a wall, map on a table etc.
I'm pretty sure i could use this data to generate the actual game world based on this, if i wanted to; without height-map information, of course. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: osmlove library (OSM maps in your Love2D projects)

Post by dusoft »

Indeed, creating worlds based on this was my goal (creating street network for transport game) - that's basically, why I have decided to develop this.
User avatar
mtdev
Prole
Posts: 20
Joined: Mon Feb 20, 2017 5:10 am
Location: Midwest US

Re: osmlove library (OSM maps in your Love2D projects)

Post by mtdev »

Can it create a simple political map of a region? It would be cool to be able to select individual countries, states, provinces, etc. Could be so many possibilities :)
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: osmlove library (OSM maps in your Love2D projects)

Post by pedrosgali »

This is incredibly cool, I had no idea I wanted this until I saw it and now I can't stop thinking about what I could make with it. Good job.

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: osmlove library (OSM maps in your Love2D projects)

Post by dusoft »

mtdev wrote: Mon Apr 03, 2017 1:43 pm Can it create a simple political map of a region? It would be cool to be able to select individual countries, states, provinces, etc. Could be so many possibilities :)
Indeed, it can draw anything based on the preset rules. However, as of now only rules for "highway" type of "ways" are supported.
See for OSM element details: https://wiki.openstreetmap.org/wiki/Elements
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: osmlove library (OSM maps in your Love2D projects)

Post by dusoft »

Enjoy early alpha (v0.1):
https://github.com/nekromoff/osmlove
Attachments
Example with different rules (colors and alpha) applied
Example with different rules (colors and alpha) applied
osmlove3.png (472.45 KiB) Viewed 7847 times
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: osmlove library (OSM maps in your Love2D projects)

Post by dusoft »

Please, send me your ideas on what to prioritize during development. What would you use this in your games for?

Generating worlds based on maps? If yes, is data table with existing structures (roads, rivers etc.) useful for you?

Drawing maps in-game? If yes, what further options you need for drawing?

Etc.

Any feedback welcome!
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: osmlove library (OSM maps in your Love2D projects)

Post by zorg »

A questions:
The init function has a few parameters, but it's somewhat unclear what they really do.
The file is of course self-explanatory, the region limits are there, i assume, because one might download a bigger map, and may only want part of it to be used in-game at a time, for example.
The width and height will be the canvas properities, i suppose.
So, if you define the usable area in terms of the input area, and the usable area in terms of the output graphic, what does the zoom parameter do? Or rather, which other parameter(s) will it modify?

A few ideas:
- Make the library be stateless, in the sense that currently, you require the lib once, and it stores one map you load; it can't create more than one at a time. Here's an interesting read on the subject: http://kiki.to/blog/2014/04/11/rule-4-m ... s-modules/
- Since this is for Löve, i'd prioritize rewriting lua io functions into love.filesystem ones.
- _setupMap resets the active canvas to the screen at its end; you don't know what someone may have set it before calling this function, so you should either store that info in the function with the similarly named getter, and set it back to that at the end of the function, or use love.graphics.push('all'), since that also stores the active canvas, i believe (with that parameter).
- Have a separate function for setting the (coloring) rules, and not do it per-frame with osmlove.drawMap
- Also don't force the alpha+premultiplied drawmode on people; maybe mention it that it should be used.
- This one's a tiny nitpick, but maybe just have the above function be named draw? it would be shorter and more consistent with Löve's API.
- (Similarly, init -> load, though if it's not exposed, it doesn't matter.)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests