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

Crash when only one feature #30

Open
scaddenp opened this issue May 4, 2017 · 15 comments
Open

Crash when only one feature #30

scaddenp opened this issue May 4, 2017 · 15 comments

Comments

@scaddenp
Copy link

scaddenp commented May 4, 2017

(node:13548) DeprecationWarning: process.EventEmitter is deprecated. Use require
('events') instead.
info: Number of features for service: 1
info: Getting chunks of 100 features...
info: query -> 0 out of 1
C:\AGStoShapefile-master\AGStoSHP.js:71
objectIds.sort();
^

TypeError: Cannot read property 'sort' of null
at requestService (C:\AGStoShapefile-master\AGStoSHP.js:71:11)
at Request._callback (C:\AGStoShapefile-master\AGStoSHP.js:64:4)
at Request.self.callback (C:\AGStoShapefile-master\node_modules\request\requ
est.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (C:\AGStoShapefile-master\node_modules\request\reques
t.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (C:\AGStoShapefile-master\node_modules\reques
t\request.js:1091:12)
at IncomingMessage.g (events.js:292:16)

C:\AGStoShapefile-master>node AGStoSHP.js services.txt W:/NZPM_Shapefiles

@tannerjt
Copy link
Owner

tannerjt commented May 4, 2017

Interesting. Can you try logging the output out objectIds on line 71: console.log(objectIds). I guess I never accounted for what would happen with one feature. I am assuming ArcGIS Server is returning a single integer and not an array of integers. Since sort is not a method of a number, it is throwing an error.

@tannerjt
Copy link
Owner

tannerjt commented May 4, 2017

The best thing to do is probably check to see if is an array

if(!Array.isArray(objectIds)) objectIds = [objectIds]

@scaddenp
Copy link
Author

scaddenp commented May 4, 2017

Having to work slowly through the service list to find which one is the issue - however, I find that unsurprizingly, it also crashes when service return empty (not uncommon in this instance - it is shapefile of permits and want weekly update as changes often and can none).

@tannerjt
Copy link
Owner

tannerjt commented May 4, 2017

I really should have better logging and error handling. It's been on my todo list. It would save time if at the end it just said... https://.../1 failed but still processed the rest.

@tannerjt
Copy link
Owner

tannerjt commented May 4, 2017

If it returns empty, does it return undefined or some standard? If it returned an empty array, or a boolean value we could easily detect.

@scaddenp
Copy link
Author

scaddenp commented May 4, 2017

I am getting it on an odd one:
Added console.log(serverUrl) so I can see which service fails and you can see the service I am using.

(node:6308) DeprecationWarning: process.EventEmitter is deprecated. Use require(
'events') instead.
http://data.nzpam.govt.nz/arcgis/rest/services/EXTERNAL/Petroleum/MapServer/9
[ 3702, 8112, 9317 ]
info: Number of features for service: 3
info: Getting chunks of 100 features...
info: query -> 0 out of 3
http://data.nzpam.govt.nz/arcgis/rest/services/EXTERNAL/Petroleum/MapServer/3
null
C:\AGStoShapefile-master\AGStoSHP.js:73
objectIds.sort();
^

TypeError: Cannot read property 'sort' of null
at requestService (C:\AGStoShapefile-master\AGStoSHP.js:73:11)
at Request._callback (C:\AGStoShapefile-master\AGStoSHP.js:64:4)
at Request.self.callback (C:\AGStoShapefile-master\node_modules\request\requ
est.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (C:\AGStoShapefile-master\node_modules\request\reques
t.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (C:\AGStoShapefile-master\node_modules\reques
t\request.js:1091:12)
at IncomingMessage.g (events.js:292:16)

@scaddenp
Copy link
Author

scaddenp commented May 4, 2017

objectId is null.

@tannerjt
Copy link
Owner

tannerjt commented May 4, 2017

if(objectIds == null) return

if(!Array.isArray(objectIds)) objectIds = [objectIds]

I wonder if that would take care of these two (line 71)

@scaddenp
Copy link
Author

scaddenp commented May 4, 2017

Yup. That works well. Now I get:
http://data.nzpam.govt.nz/arcgis/rest/services/EXTERNAL/Minerals/MapServer/2
[ 779,
128023,
134421,
193261,
193264,
197296,
197696,
200912,
203327,
203329,
204932,
205333,
205742 ]
info: Number of features for service: 13
info: Getting chunks of 100 features...
info: query -> 0 out of 13
info: code=400, message=Invalid or missing input parameters., details=[]

@scaddenp
Copy link
Author

scaddenp commented May 4, 2017

(My services file is large so giving this a good workout).

@tannerjt
Copy link
Owner

tannerjt commented May 4, 2017

Hopefully the script is helping with some of the other services. It's not perfect, but it will usually get the job done with some minor adjustments 😄

@yipcma
Copy link

yipcma commented May 9, 2017

ya i'm getting code=400 as well... anyone got a fix?

@yipcma
Copy link

yipcma commented May 9, 2017

ok, the issue with code=400 with me is on there being sublayers....

@tannerjt
Copy link
Owner

tannerjt commented May 9, 2017

It should be straightforward to define sublayers under the root REST endpoint, and I'll look into that for future improvements. For now, all sublayers need to be defined explicitly in the services.txt file:

https://tmservices1.esri.com/arcgis/rest/services/LiveFeeds/NDFD_Precipitation/MapServer/2|Percipitation
https://tmservices1.esri.com/arcgis/rest/services/LiveFeeds/Wildfire_Activity/MapServer/0|WildFire

@yipcma
Copy link

yipcma commented May 16, 2017

i solved it by using just sublayers, not anything above (which caused the 400s)

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

3 participants