osmlove library (OSM maps in your Love2D projects)

Showcase your libraries, tools and other projects that help your fellow love users.
dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

osmlove library (OSM maps in your Love2D projects)

Post by dusoft » Sun Apr 02, 2017 7:04 pm

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.png
osmlove bratislava, zoom 2 (half city)
osmlove.png (289.31 KiB) Viewed 3686 times
osmlove2.png
osmlove addis ababa, zoom 1 (whole city)
osmlove2.png (377.9 KiB) Viewed 3681 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 » Mon Apr 03, 2017 4:32 am

Cool! Looking forward to seeing where this goes.

User avatar
zorg
Party member
Posts: 2913
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post by zorg » Mon Apr 03, 2017 6:38 am

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.

dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

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

Post by dusoft » Mon Apr 03, 2017 9:52 am

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 » 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 :)

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 » Mon Apr 03, 2017 3:54 pm

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

dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

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

Post by dusoft » Mon Apr 03, 2017 9:49 pm

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

dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

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

Post by dusoft » Thu Apr 06, 2017 9:43 pm

Enjoy early alpha (v0.1):
https://github.com/nekromoff/osmlove
Attachments
osmlove3.png
Example with different rules (colors and alpha) applied
osmlove3.png (472.45 KiB) Viewed 3385 times

dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

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

Post by dusoft » Fri Apr 07, 2017 2:03 pm

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: 2913
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post by zorg » Fri Apr 07, 2017 2:25 pm

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 10 guests