-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use node-gdal more #43
Comments
in concert with reducing dependencies, would be great to hit mapbox/node-srs#49 at some point too. |
I've started refactoring process and have come up with a couple of really minor questions: Multilayer vector datasets Output formatting
To me, it would make the most sense to me to make mapnik-omnivore output an array of mml-like Layer objects. This could lessen the number intermediate steps when going from mapnik-omnivore to carto. Really not a big deal at the moment. Would be nice to see this issue mapbox/carto#274 addressed for that to happen though. |
Hey @brandonreavis,
I think @GretaCB can comment better on this one but I don't see any reason not to calculate extent/center from all the layers in multilayer datasources.
Yep, this could use another pass but will probably be something we take on in a breaking API change in a future version maybe. OTOH combining the |
Alright I think it's getting pretty close. While removing mapnik I tried to distill things a bit and make it a bit more modular. The output should be pretty much identical to earlier though! The changes can be seen here: Changes
Breaking changes
Needed changes
Additional proposed changes
|
Awesome work @brandonreavis. Have my head down on mapbox/mapbox-studio-classic#1040 still but will review soon. |
Awesome @brandonreavis .
|
Ahh that's what the I am hesitant to do the Using chai's assert.closeTo() to do floating point tests with node-gdal has saved some time and could help with this. But yeah, I don't really want to do much with the tests or convert them to mocha until I know why they were converted to tape from mocha earlier. CSVs Is this fine? Are there any other extensions I should add? or should we always open up the file and look at the first 100 lines? |
Tape port happened to workaround that appveyor/node v0.10.x/mocha bug that caused missing log output. And because http://www.macwright.org/2014/03/11/tape-is-cool.html. The CSV row_limit is a recent addition on my suggestion. I realize now it could result in incorrect extents for the dataset so we should consider reverting back to reading the whole thing. That said supporting row_limit/estimate extent in geocsv-info is still a useful feature. Really interesting that the extents are slightly off for rasters. Mapnik is calling into gdal to get the extents so it will be interesting to see who is wrong and whether it is a bug or just floating point drift. As far as CSV extensions yes those should be good! Thanks! |
Tap/tape/mocha: Yeah, mochajs/mocha#333 was a bummer. Thankfully mochajs/mocha#1339 fixed it (it's been working fine for node-gdal). I get the pros that @tmcw lays out there for tap (all totally valid), but the limited structure for large projects and vague failure details makes it hard for outsiders to come into a project and know what's going on. |
@springmeyer, I just tested the extent right before converting it to WGS84 and it matches the output of gdalinfo identically. The error seems to be introduced when transforming the extent polygon to WGS84 here as far as I can tell.
|
Ahh found the problem. Either mapnik or the mapnik-omnivore (previously) was transforming the upper left / lower right point and setting the extent based on those points. If you imagine a rectangle rotated clockwise by a few degrees, the bottom left and top right points are what should define the extent. That's why the extent is a little wider than it was before, but the height is spot on. |
@brianreavis - wow, thanks for the links to mocha fixes. I did not know about these - I'm still using/happy with mocha in node-mapnik so do I just need to upgrade to mocha 2.x to get node v0.10.x+mocha+appveyor output working? @brandonreavis - wrt to the extent differences - so do you see any action that we need to take? Do the results still differ between gdal and mapnik? |
@springmeyer - Yeah, it seems like this should be fixed in node-mapnik here: double minx = a->Get(0)->NumberValue();
double miny = a->Get(1)->NumberValue();
double maxx = a->Get(2)->NumberValue();
double maxy = a->Get(3)->NumberValue();
p->projection_->forward(minx,miny);
p->projection_->forward(maxx,maxy);
Local<Array> arr = NanNew<Array>(4);
arr->Set(0, NanNew(minx));
arr->Set(1, NanNew(miny));
arr->Set(2, NanNew(maxx));
arr->Set(3, NanNew(maxy));
NanReturnValue(arr); should become something like this: double ulx, ulx, urx, ury, lrx, lry, llx, lly;
ulx = llx = a->Get(0)->NumberValue();
lry = lly = a->Get(1)->NumberValue();
lrx = urx = a->Get(2)->NumberValue();
uly = ury = a->Get(3)->NumberValue();
p->projection_->forward(ulx,uly);
p->projection_->forward(urx,ury);
p->projection_->forward(lrx,lry);
p->projection_->forward(llx,lly);
Local<Array> arr = NanNew<Array>(4);
arr->Set(0, NanNew(ulx<llx ? ulx : llx));
arr->Set(1, NanNew(lry<lly ? lry : lly));
arr->Set(2, NanNew(urx>lrx ? urx : lrx));
arr->Set(3, NanNew(ury>uly ? ury : uly));
NanReturnValue(arr); |
Turns out it also would need to be changed in mapnik too: https://github.com/mapnik/mapnik/blob/master/src/proj_transform.cpp#L200 The backward methods would need a similar fix. |
@brandonreavis - Okay, thank you.
Is there documentation you know of describing this as the ideal method for bbox calculations? /cc @artemp |
Hmm not that I know of. Can a coordinate transformation ever mirror about the x axis? Safest thing to do would be just to recompute the extent based on all the corners like: minx = Math.min(ulx, urx, lrx, llx) |
@springmeyer Looks like I was wrong... seems like it's not in master yet. We're waiting on: mochajs/mocha#1440. For a workaround see: https://github.com/naturalatlas/node-gdal/blob/master/appveyor.yml#L37 (I won't be deleting that branch until 1440 is merged) |
@brianreavis @springmeyer - re-projecting all four corners sounds good. |
Update on my thinking here:
Here are the steps I'm seeing (for Jan/Feb 2015):
After those steps are done then we'd be able to move on getting mapnik-omnivore updated to use new node-gdal to be able to bring in fixes from https://github.com/naturalatlas/mapnik-omnivore/tree/gdal-refactor. Other followups:
|
Also just updated the ticket name to avoid confusion: now says |
This happened!
This also happened. These were the key last things keeping this ticket open. Closing now. Overall we want and are going to keep using both mapnik and gdal in omnivore and this is working well. |
We need to replace temporary code like this to use node-gdal, and why not actually just try to use node-gdal everywhere instead of needing node-mapnik around? The vision behind omnivore is to figure out the right metadata in order to pass along to Mapnik for fast reading of the data. Mapnik itself does not need to be involved in figuring out this metadata.
/cc @brandonreavis who I've been chatting with about this.
The text was updated successfully, but these errors were encountered: