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

Radius Query. Cannot read property 'getRectBound' of undefined #8

Open
ildar-icoosoft opened this issue Sep 24, 2017 · 5 comments
Open

Comments

@ildar-icoosoft
Copy link

I get error "Cannot read property 'getRectBound' of undefined" if radius is greater than 1063652 meters.

Herre is my code:

myGeoTableManager.queryRadius({
    RadiusInMeter: radius,
    CenterPoint: {
        longitude: longitude,
        latitude: latitude,
    }
})

Here is the stack trace:

TypeError: Cannot read property 'getRectBound' of undefined
    at S2LatLngRect.mayIntersectC (/var/task/node_modules/nodes2ts/dist/S2LatLngRect.js:515:39)
    at S2RegionCoverer.newCandidate (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:210:26)
    at S2RegionCoverer.getInitialCandidates (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:341:36)
    at S2RegionCoverer.getCoveringInternal (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:366:14)
    at S2RegionCoverer.getCoveringUnion (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:181:14)
    at S2RegionCoverer.getCoveringCells (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:156:24)
    at GeoDataManager.queryRadius (/var/task/node_modules/dynamodb-geo/dist/GeoDataManager.js:205:82)
    at _callee$ (/var/task/handler.js:138:38)
    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:65:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:299:22)
@lantikchi
Copy link

I have the same issue. Is there a fix for this issue?

@robhogan
Copy link
Owner

robhogan commented Apr 8, 2018

It turns out this is a bug in nodes2ts but the fix is still unreleased.

An ugly-but-effective option is to patch nodes2ts at run-time with:

require('nodes2ts').S2RegionCoverer.FACE_CELLS = [0, 1, 2, 3, 4, 5].map(face => S2Cell.fromFacePosLevel(face, 0, 0));

Running that once before using either radius or rectangle queries should be enough. If the author of nodes2ts doesn't release a new version soon I'll add that patch to this lib.

@Sh3nr0n
Copy link

Sh3nr0n commented Jul 4, 2018

Hi sorry for the rookie question, but how do you actually "patch nodes2ts at run-time"?
More precisely, where am I supposed to require the following line of code?
I get a similar error but with the "queryRectangle()", here is the stack trace:

TypeError: Cannot read property 'getRectBound' of undefined
at S2LatLngRect.mayIntersectC (/var/task/node_modules/nodes2ts/dist/S2LatLngRect.js:515:40)
at S2RegionCoverer.newCandidate (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:210:26)
at S2RegionCoverer.getInitialCandidates (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:341:36)
at S2RegionCoverer.getCoveringInternal (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:366:14)
at S2RegionCoverer.getCoveringUnion (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:181:14)
at S2RegionCoverer.getCoveringCells (/var/task/node_modules/nodes2ts/dist/S2RegionCoverer.js:156:24)
at GeoDataManager.queryRectangle (/var/task/node_modules/dynamodb-geo/dist/GeoDataManager.js:176:82)
at module.exports (/var/task/garden-handler.js:599:26)
at exports.graphqlHandler (/var/task/garden-handler.js:253:9)

Any help would be appreciated!

@robhogan
Copy link
Owner

robhogan commented Jul 4, 2018

Put that line in your own app's code, anywhere you like (once per-process should be enough) as long as it's before you call queryRadius or queryRectangle.

You could put it right on the line before your queryRadius call if you like, but somewhere in your app's init might be neater - up to you.

@Sh3nr0n
Copy link

Sh3nr0n commented Jul 4, 2018

Thanks for your help, I'll try that!

joenye pushed a commit to joenye/dynamodb-geo.js that referenced this issue Oct 12, 2020
Issue is described here: robhogan#8
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

No branches or pull requests

4 participants