Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for encoding data as a raw image bitmap to UTF grids #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcuelenaere
Copy link

This adds support for getting the raw image data rendered by the
mapnik grid renderer. The data is returned as 64-bit signed integers or
32-bit signed integers (host endian), depending on whether BIGINT
is true or not.

This adds support for getting the raw image data rendered by the
mapnik grid renderer. The data is returned as 64-bit signed integers or
32-bit signed integers (host endian), depending on whether BIGINT
is true or not.
@flippmoke
Copy link
Member

I am somewhat confused by this, why not just use the Image object to get raw image data

@mcuelenaere
Copy link
Author

@flippmoke How would you access the Image object? AFAICS, there's no way to access the underlying buffer from a mapnik::grid or mapnik::grid_view through the current Python bindings (except perhaps by repeatedly calling the get_pixel() method)

@flippmoke
Copy link
Member

My question is more why are you using a grid object rather then an Image object.

https://github.com/mapnik/python-mapnik/blob/master/src/mapnik_image.cpp#L454-L456

tostring might be helpful then for what you are looking to do?

@flippmoke
Copy link
Member

Also if you did want the raw character buffer from the grid does that really help because you wouldn't have a mapping to what the character were?

@mcuelenaere
Copy link
Author

@flippmoke I experimented with UTF grid, but found its resolution to be too low for our use case and increasing the resolution inflates the JSON too much. So by getting the raw grid data (which is basically an array of 64-bits containing the feature IDs (which can be downscaled to 32-bit, 16-bit or 8-bit; depending on the amount of features)), we want to send these as images down to the client and extract the data to get the corresponding feature ID in JavaScript. A mapping to the actual feature metadata will be provided out of band, eg with a static JSON file.

@flippmoke
Copy link
Member

Okay that makes more sense. So some things I want to talk about before we would be able to merge something to help you out.

  • I am not sure about the API here, encoding was originally so that we could provide different strings types of the same JSON output. I would rather not change this to raw as it is a different context for the entire method. Therefore, I would suggest this be a different method all together
  • Your pull request request doesn't include any tests for this code. One of our goals in all our mapnik repositories is to get to 100% test coverage. I haven't yet setup coveralls for python mapnik, but I do want to see any new code well tested.

If you need any help towards achieving these things let me know please, more then willing to give input or help.

Thanks for your pull request!

@mcuelenaere
Copy link
Author

Sure, what API are you suggesting? getRawData()?

I'm off the coming week so I probably won't be responsive.

@flippmoke
Copy link
Member

That would be fine, do we need to have a way to retrieve what the raw symbols mean then at this point, etc. If they are not included in the getRawData.

@mcuelenaere
Copy link
Author

Aren't the raw symbols the feature IDs? Unless you want to keep that an implementation-specific thing and allow for changing the meaning in the future? (in which case you do need a mapping)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants