{"record":{"id":"e89a28a833c43236","repo":"mrdoob/three.js","slug":"unsupported-shape-type-type","errorCode":null,"errorMessage":"unsupported shape type: ${type}","messagePattern":"unsupported shape type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"manual/resources/tools/geo-picking/shapefile.js","lineNumber":372,"sourceCode":"  13: parsePolyLine, // PolyLineZ\n  15: parsePolygon, // PolygonZ\n  18: parseMultiPoint, // MultiPointZ\n  21: parsePoint, // PointM\n  23: parsePolyLine, // PolyLineM\n  25: parsePolygon, // PolygonM\n  28: parseMultiPoint // MultiPointM\n};\n\nvar shp = function(source) {\n  source = slice(source);\n  return source.slice(100).then(function(array) {\n    return new Shp(source, view(array));\n  });\n};\n\nfunction Shp(source, header) {\n  var type = header.getInt32(32, true);\n  if (!(type in parsers)) throw new Error(\"unsupported shape type: \" + type);\n  this._source = source;\n  this._type = type;\n  this._index = 0;\n  this._parse = parsers[type];\n  this.bbox = [header.getFloat64(36, true), header.getFloat64(44, true), header.getFloat64(52, true), header.getFloat64(60, true)];\n}\n\nvar prototype$2 = Shp.prototype;\nprototype$2.read = shp_read;\nprototype$2.cancel = cancel;\n\nfunction noop() {}\n\nvar shapefile_cancel = function() {\n  return Promise.all([\n    this._dbf && this._dbf.cancel(),\n    this._shp.cancel()\n  ]).then(noop);","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/manual/resources/tools/geo-picking/shapefile.js#L354-L390","documentation":"Thrown by the Shp constructor when the .shp file header's shape-type code (little-endian int32 at byte offset 32) is not a key in the parsers map. Supported codes are 0 (Null), 1/11/21 (Point variants), 3/13/23 (PolyLine), 5/15/25 (Polygon), and 8/18/28 (MultiPoint). Any other value — including future/proprietary shape types — is rejected at parse time.","triggerScenarios":"Reading a .shp file whose declared shape type is outside the ESRI types the reader implements (e.g. type 31 MultiPatch, or any vendor-specific code). Reading a corrupt .shp where the bytes at offset 32 do not form a valid type code.","commonSituations":"Using a natural-earth or OSM-derived shapefile that happens to use MultiPatch (3D multipatch, type 31). Feeding a non-.shp binary (or a .shx/.dbf) to the .shp parser so the type field is random.","solutions":["Confirm the input file is a valid .shp and inspect its declared type code (read int32 LE at offset 32).","If the type is genuinely one you need (e.g. 31 MultiPatch), add a parser function and register it in the parsers map at shapefile.js:347.","If the file is corrupt, re-export the shapefile from QGIS/GDAL as a supported type (Polygon, PolyLine, Point)."],"exampleFix":"// before — file declares type 31 (MultiPatch), not in parsers\nvar parsers = { 0: parseNull, 1: parsePoint, /* ... 28: parseMultiPoint */ };\n\n// after — add a parser for the type you need\nvar parsers = {\n  0: parseNull, 1: parsePoint, /* ... */ 28: parseMultiPoint,\n  31: parseMultiPatch,\n};","handlingStrategy":"validation","validationCode":"const SUPPORTED_SHP_TYPES = new Set( [ 0, 1, 3, 5, 8, 11, 13, 15, 18, 21, 23, 25, 28 ] );\nfunction assertShpType( type ) {\n  if ( ! SUPPORTED_SHP_TYPES.has( type ) ) {\n    throw new Error( `unsupported shape type: ${type}` );\n  }\n}","typeGuard":"const SUPPORTED_SHP_TYPES = new Set( [ 0, 1, 3, 5, 8, 11, 13, 15, 18, 21, 23, 25, 28 ] );\nfunction isSupportedShpType( type ) {\n  return SUPPORTED_SHP_TYPES.has( type );\n}","tryCatchPattern":"try {\n  shp = await shp( source );\n} catch ( err ) {\n  if ( /unsupported shape type/.test( err.message ) ) {\n    throw new Error( 'This shapefile uses a geometry type the reader cannot handle. Re-export as Polygon/PolyLine/Point.' );\n  }\n  throw err;\n}","preventionTips":["Inspect the .shp header type code (int32 LE at offset 32) before parsing.","Register a parser in the parsers map (shapefile.js:347) for any new type you need.","Re-export exotic shapefiles (e.g. MultiPatch) to a supported type via GDAL/QGIS."],"tags":["geo","manual","shapefile","switch-enum","parsing"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}