Comments (15)
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.
from agstoshapefile.
The best thing to do is probably check to see if is an array
if(!Array.isArray(objectIds)) objectIds = [objectIds]
from agstoshapefile.
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).
from agstoshapefile.
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.
from agstoshapefile.
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.
from agstoshapefile.
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)
from agstoshapefile.
objectId is null.
from agstoshapefile.
if(objectIds == null) return
if(!Array.isArray(objectIds)) objectIds = [objectIds]
I wonder if that would take care of these two (line 71)
from agstoshapefile.
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=[]
from agstoshapefile.
(My services file is large so giving this a good workout).
from agstoshapefile.
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 😄
from agstoshapefile.
ya i'm getting code=400 as well... anyone got a fix?
from agstoshapefile.
ok, the issue with code=400 with me is on there being sublayers....
from agstoshapefile.
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
from agstoshapefile.
i solved it by using just sublayers, not anything above (which caused the 400s)
from agstoshapefile.
Related Issues (20)
- No shapefile output (bigdata branch) HOT 3
- error code 500? HOT 1
- TypeError: Cannot read property 'push' of undefined
- Cannot read property '0' of undefined HOT 1
- TypeError: Cannot read property 'attributes' of undefined HOT 3
- Error after finished extracting chunks. How to merge multiple JSON files to single GeoJSON file? HOT 4
- Partial JSON argument due to GeoJSON big file size
- Type error in terraformer HOT 2
- Print better failure message
- Too many open files.... Is it possible to increase the chunk size from 100 to say... 1000? HOT 7
- Cannot read property 'spatialReference' of undefined
- I am getting TypeError: Cannot read property 'sort' of null
- Feature Missing Geometry and is Omitted
- TypeError: Cannot read property 'sort' of undefined. HOT 2
- Error: read ECONNRESET
- Is it possible to have a web interface to enter the service url?
- npm deprecation/notsup warnings
- ReferenceError: primordials is not defined HOT 4
- ReferenceError: geojsonStream is not defined HOT 1
- Code modification for error 502
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agstoshapefile.