modestmap pygame/pyglet tilesets
I'm trying to get modest map work on top of pygame and pyglet, is there a way to get next tile if I get the PIL image with mapByExtent (I need next image of the same dimensions to construct tileset) I tried to get next tile with map.pointLocation(point) but for some reason it doesn't do what I expect.
The thing that confuses me is that the location and point from location is giving me different values:
self.map = ModestMaps.mapByExtent(self.provider, self.locationA, self.locationB, self.dimensions)
print self.locationA,self.locationB
point = ModestMaps.Core.Point (0,0)
print self.map.pointLocation(point)
point = ModestMaps.Core.Point (512,512)
print self.map.pointLocation(point)
I have the image defaulting to 512x512 as seen above.
Any help or tip is appreciated :)
The thing that confuses me is that the location and point from location is giving me different values:
self.map = ModestMaps.mapByExtent(self.provider, self.locationA, self.locationB, self.dimensions)
print self.locationA,self.locationB
point = ModestMaps.Core.Point (0,0)
print self.map.pointLocation(point)
point = ModestMaps.Core.Point (512,512)
print self.map.pointLocation(point)
I have the image defaulting to 512x512 as seen above.
Any help or tip is appreciated :)
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?I'm not overly familiar with the python code, so I might not be able to un-stick you alone. But hopefully I can provide a tip :)
Have you tried printing map.locationPoint(locationA) – do you get 0,0? If not I would suspect an error with the projection in your provider. Can you post the values for your provider? -
Inappropriate?As far as getting the next tile goes, take a look at the Coordinate data type in Core.py too. Looping over Coordinates for each zoom level and getting the Location of the corners of each one would be a good way to draw tiles. If you have a coordinate, then coordinate.right().down() will give you the bottom right corner of that tile, and provider.coordinateLocation(coordinate) will give you the Location (lat/lon) if you need that to choose what data to render.
-
Inappropriate?Well I found a way with experimenting. Now I'm using:
self.map = ModestMaps.mapByExtentZoom(self.provider, self.locationA, self.locationB, 15)
and I calculate the next tile with fixed latrate=-.0156, lonrate=.022
For now I'm able to produce exact matches and build the background.
I'll go deeper into modestmaps code later as I never do that in hurry, it must lay down for few days or I get headache :)
Anyway as soon this become something usable I'll share the project in the community with some gpl license, as this is intended for use with multitouch surfaces.
Ps. error could be because I use svn version of modestmaps, as the release has an issue with displaying googlemaps at least the one I downloaded. And btw. thnx for the tip
I’m happy
-
Inappropriate?Hi Goran,
getMapByExtentZoom is definitely the thing you want.
You'll notice that getMapByExtent accepts image dimensions, which means that it takes two locations and does its best to fit them inside a given map image. This means that the locations may or may not actually end up right at the map corners - in fact they usually don't, they're just guaranteed to fit someplace. The intent of this function is to create maps like this one, where you know what points you want to show and how big it should be, but don't otherwise care where, precisely, those point ssit on the map:
http://oakland.crimespotting.org/beat...
By contrast, getMapByExtentZoom determines an appropriate image size based on precise corner locations, which sounds closer in spirit to what you're aiming for.
Can you explain more about pygame and pyglet? It sounds like you're generating 512x512 tiles from the output of maps. There may be a better or more efficient way to do this directly with a custom provider.
Sorry about the Google maps thing. They change their tile URLs a lot, it's hard for us to keep up. We strongly recommend a more stable mapping provider like Microsoft or OpenStreetMap.
I’m stoked someone's using the python port
-
Inappropriate?Hi Migurski,
Well, everything is in the early stage. I managed to build tilesets and display/move trough them in pygame and pyglet gl. I choose 512x512 size as that seems something fair in size (file and display size) for caching. Intent is to use bigger zoomed out images and then on request zoom them in. Right now I'm playing with both frameworks just to see which one would be easier to implement. And I'm looking on how to make dynamic surface buffer so I can add other tiles when viewport reaches the edges of the buffer.
I’m starting to have headache
Loading Profile...



EMPLOYEE
EMPLOYEE