Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11988

Cant create 2dsphere index on array of GeoJSON LineString: ""Can't extract geo keys from object, malformed geometry?"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.5.4
    • Geo
    • Gentoo Linux amd64
    • Linux
    • Hide

      1.) insert document mentioned previously
      2.) Try to create 2dsphere index on field 'segments'

      Show
      1.) insert document mentioned previously 2.) Try to create 2dsphere index on field 'segments'

    Description

      I have a database containing way segments from OpenStreetMap stored as an array of GeoJSON LineString objects:

      > db.ways.findOne({}, { segments: true})
      {
      	"segments" : [
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2228032,
      					50.8051785
      				],
      				[
      					7.2226525,
      					50.8054414
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2226525,
      					50.8054414
      				],
      				[
      					7.2224028,
      					50.805692
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2224028,
      					50.805692
      				],
      				[
      					7.2217995,
      					50.8062804
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2217995,
      					50.8062804
      				],
      				[
      					7.2215501,
      					50.8065347
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2215501,
      					50.8065347
      				],
      				[
      					7.2210556,
      					50.8070833
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2210556,
      					50.8070833
      				],
      				[
      					7.2208635,
      					50.8074685
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2208635,
      					50.8074685
      				],
      				[
      					7.2200495,
      					50.8082661
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2200495,
      					50.8082661
      				],
      				[
      					7.2200803,
      					50.8084219
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2200803,
      					50.8084219
      				],
      				[
      					7.2201153,
      					50.808599
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2201153,
      					50.808599
      				],
      				[
      					7.2200909,
      					50.8087172
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2200909,
      					50.8087172
      				],
      				[
      					7.2198782,
      					50.8088329
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2198782,
      					50.8088329
      				],
      				[
      					7.218674,
      					50.8100349
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.218674,
      					50.8100349
      				],
      				[
      					7.2179697,
      					50.8103464
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2179697,
      					50.8103464
      				],
      				[
      					7.2176172,
      					50.8104984
      				]
      			]
      		},
      		{
      			"type" : "LineString",
      			"coordinates" : [
      				[
      					7.2176172,
      					50.8104984
      				],
      				[
      					7.2168889,
      					50.8111111
      				]
      			]
      		}
      	],
      	"_id" : ObjectId("52a086fe2308d1ac1e000001")
      }

      Trying to create a 2dsphere index throws the following error:

      > db.ways.ensureIndex({segments : "2dsphere"})
      {
      	"err" : "Can't extract geo keys from object, malformed geometry?: { tags: { highway: \"service\", service: \"parking_aisle\" }, nodeRefs: [ \"270524743\", \"1633119639\", \"1633119637\", \"1633119640\", \"1633119638\", \"510854\", \"510855\", \"11766986\", \"1744718756\", \"11766983\", \"1744718765\", \"11766978\", \"11766975\", \"510863\", \"510864\", \"510865\" ], id: \"4008272\", nodes: [ { tags: {}, id: \"270524743\", lat: 50.8051785, lon: 7.2228032 }, { tags: {}, id: \"1633119639\", lat: 50.8054414, lon: 7.2226525 }, { tags: {}, id: \"1633119637\", lat: 50.805692, lon: 7.2224028 }, { tags: {}, id: \"1633119640\", lat: 50.8062804, lon: 7.2217995 }, { tags: {}, id: \"1633119638\", lat: 50.8065347, lon: 7.2215501 }, { tags: { created_by: \"JOSM\", ele: \"84.2526855469\", time: \"2004-12-28T16:40:08Z\" }, id: \"510854\", lat: 50.8070833, lon: 7.2210556 }, { tags: { ele: \"84.2526855469\", time: \"2004-12-28T16:40:13Z\" }, id: \"510855\", lat: 50.8074685, lon: 7.2208635 }, { tags: {}, id: \"11766986\", lat: 50.8082661, lon: 7.2200495 }, { tags: {}, id: \"1744718756\", lat: 50.8084219, lon: 7.2200803 }, { tags: {}, id: \"11766983\", lat: 50.808599, lon: 7.2201153 }, { tags: {}, id: \"1744718765\", lat: 50.8087172, lon: 7.2200909 }, { tags: {}, id: \"11766978\", lat: 50.8088329, lon: 7.2198782 }, { tags: {}, id: \"11766975\", lat: 50.8100349, lon: 7.218674 }, { tags: {}, id: \"510863\", lat: 50.8103464, lon: 7.2179697 }, { tags: {}, id: \"510864\", lat: 50.8104984, lon: 7.2176172 }, { tags: {}, id: \"510865\", lat: 50.8111111, lon: 7.2168889 } ], segments: [ { type: \"LineString\", coordinates: [ [ 7.2228032, 50.8051785 ], [ 7.2226525, 50.8054414 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2226525, 50.8054414 ], [ 7.2224028, 50.805692 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2224028, 50.805692 ], [ 7.2217995, 50.8062804 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2217995, 50.8062804 ], [ 7.2215501, 50.8065347 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2215501, 50.8065347 ], [ 7.2210556, 50.8070833 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2210556, 50.8070833 ], [ 7.2208635, 50.8074685 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2208635, 50.8074685 ], [ 7.2200495, 50.8082661 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2200495, 50.8082661 ], [ 7.2200803, 50.8084219 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2200803, 50.8084219 ], [ 7.2201153, 50.808599 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2201153, 50.808599 ], [ 7.2200909, 50.8087172 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2200909, 50.8087172 ], [ 7.2198782, 50.8088329 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2198782, 50.8088329 ], [ 7.218674, 50.8100349 ] ] }, { type: \"LineString\", coordinates: [ [ 7.218674, 50.8100349 ], [ 7.2179697, 50.8103464 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2179697, 50.8103464 ], [ 7.2176172, 50.8104984 ] ] }, { type: \"LineString\", coordinates: [ [ 7.2176172, 50.8104984 ], [ 7.2168889, 50.8111111 ] ] } ], _id: ObjectId('52a086fe2308d1ac1e000001') }",
      	"code" : 16755,
      	"n" : 0,
      	"connectionId" : 2,
      	"ok" : 1
      }

      I checked the format with http://geojsonlint.com/ but everything seems to be correct. Am I missing something or is indexing such an array not supported yet?

      Attachments

        Activity

          People

            Unassigned Unassigned
            maestro_alubia Fabian Köster
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: