Coder Social home page Coder Social logo

Comments (15)

tannerjt avatar tannerjt commented on June 11, 2024

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.

tannerjt avatar tannerjt commented on June 11, 2024

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

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

from agstoshapefile.

scaddenp avatar scaddenp commented on June 11, 2024

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.

tannerjt avatar tannerjt commented on June 11, 2024

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.

tannerjt avatar tannerjt commented on June 11, 2024

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.

scaddenp avatar scaddenp commented on June 11, 2024

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.

scaddenp avatar scaddenp commented on June 11, 2024

objectId is null.

from agstoshapefile.

tannerjt avatar tannerjt commented on June 11, 2024
if(objectIds == null) return

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

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

from agstoshapefile.

scaddenp avatar scaddenp commented on June 11, 2024

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.

scaddenp avatar scaddenp commented on June 11, 2024

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

from agstoshapefile.

tannerjt avatar tannerjt commented on June 11, 2024

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.

yipcma avatar yipcma commented on June 11, 2024

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

from agstoshapefile.

yipcma avatar yipcma commented on June 11, 2024

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

from agstoshapefile.

tannerjt avatar tannerjt commented on June 11, 2024

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.

yipcma avatar yipcma commented on June 11, 2024

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

from agstoshapefile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.