AGStoShapefile icon indicating copy to clipboard operation
AGStoShapefile copied to clipboard

Type error in terraformer

Open nsotelo opened this issue 7 years ago • 2 comments

The program is failing to download all of the json files from a particular server, for me it keeps crashing at the 33rd file. error_output.txt services.txt

nsotelo avatar Mar 08 '18 17:03 nsotelo

This is old, but I am also having this issue.

agsout -s ./services.txt -o . -S
Number of features for service i07_WellCompletionReports: 994757
Getting chunks of 100 features, will make 9948 total requests
/usr/local/lib/node_modules/agsout/node_modules/terraformer/terraformer.js:674
        throw new Error("Unknown type: " + geojson.type);
        ^

Error: Unknown type: undefined
    at new Primitive (/usr/local/lib/node_modules/agsout/node_modules/terraformer/terraformer.js:674:15)
    at Object.parse (/usr/local/lib/node_modules/agsout/node_modules/terraformer-arcgis-parser/terraformer-arcgis-parser.js:330:12)
    at convert (/usr/local/lib/node_modules/agsout/index.js:166:33)
    at Parser.parser.onValue (/usr/local/lib/node_modules/agsout/node_modules/JSONStream/index.js:109:32)
    at Parser.proto.emit (/usr/local/lib/node_modules/agsout/node_modules/jsonparse/jsonparse.js:337:8)
    at Parser.proto.pop (/usr/local/lib/node_modules/agsout/node_modules/jsonparse/jsonparse.js:332:8)
    at Parser.proto.onToken (/usr/local/lib/node_modules/agsout/node_modules/jsonparse/jsonparse.js:402:12)
    at Parser.parser.onToken (/usr/local/lib/node_modules/agsout/node_modules/JSONStream/index.js:128:12)
    at Parser.proto.write (/usr/local/lib/node_modules/agsout/node_modules/jsonparse/jsonparse.js:135:34)
    at Stream.<anonymous> (/usr/local/lib/node_modules/agsout/node_modules/JSONStream/index.js:23:12)
    at Stream.stream.write (/usr/local/lib/node_modules/agsout/node_modules/through/index.js:26:11)
    at Request.ondata (internal/streams/legacy.js:16:26)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/agsout/node_modules/request/request.js:1080:12)
    at emitOne (events.js:96:13)
    at IncomingMessage.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at IncomingMessage.Readable.push (_stream_readable.js:134:10)
    at HTTPParser.parserOnBody (_http_common.js:123:22)
    at TLSSocket.socketOnData (_http_client.js:377:20)
    at emitOne (events.js:96:13)

Services.txt http://gis-proxy.water.ca.gov/arcgis/rest/services/Environment/i07_WellCompletionReports/FeatureServer/0|i07_WellCompletionReports|100

vahtos avatar Mar 28 '19 13:03 vahtos

After reviewing the error and source code, it looks like the it is happening in this function:

			if(!feature.geometry) {
				console.log("Feature Missing Geometry and is Omitted: ", JSON.stringify(feature))
				return null;
			}
			const gj = {
				type: 'Feature',
				properties: feature.attributes,
				geometry: TerraformerArcGIS.parse(feature.geometry)
			}
			return gj
		}

If a feature in the dataset does not have geometry(feature.geometry is undefined), then TerraformerArcGIS.parse is being passed undefined, instead of a geometry object. But I am confused because it looks like that's being checked for, so I don't understand how this error is happening...

vahtos avatar Mar 28 '19 14:03 vahtos