RethinkDB r.polygon() - GeoJSON LinearRing에는 최소 4개의 위치가 있어야 합니까? (RethinkDB r.polygon() - GeoJSON LinearRing must have at least four positions?)


문제 설명

RethinkDB r.polygon() ‑ GeoJSON LinearRing에는 최소 4개의 위치가 있어야 합니까? (RethinkDB r.polygon() ‑ GeoJSON LinearRing must have at least four positions?)

내 데이터베이스에 geoJSON 폴리곤을 삽입하는 데 문제가 있습니다.

삽입하려는 데이터는 다음과 같습니다.

{
    "feature": {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [
                    ‑71.17351189255714,
                    42.350224666504324
                ],
                [
                    ‑71.1677360907197,
                    42.34671571695422
                ],
                [
                    ‑71.16970919072628,
                    42.35326835618748
                ],
                [
                    ‑71.14341516047716,
                    42.36174674733808
                ],
                [
                    ‑71.17559093981981,
                    42.368232175909064
                ],
                [
                    ‑71.17351189255714,
                    42.350224666504324
                ]
            ]
        },
        "properties": {}
    },
    "name": "New Polygon"
}

여기에 내가 시도하는 코드가 있습니다. 실행하려면:

r.table( 'homebases' ).insert( {
    xid: data.xid,
    name: data.name,
    geoType: "polygon",
    geoPoly: r.geojson( data.feature.geometry )
} ).run().then( function ( doc ) {
    return res.send( doc.generated_keys[ 0 ] )
} ).error( function ( err ) {
    console.error( err.message )
    return res.send( 500, err.message )
} )

이 오류가 발생했습니다:

GeoJSON LinearRing must have at least four positions

geoJSON으로 정확히 동일한 작업을 수행할 수 있으므로 여기에서 무슨 일이 일어나고 있는지 잘 모르겠습니다. 포인트 및 그것은 훌륭하게 작동합니다. API 문서에는 'type': 'Polygon' geoJSON 개체를 추가할 수 있다고 나와 있습니다.

모든 곳에서 검색을 시도했지만 솔루션을 찾을 수 없었습니다. 이 작업을 어떻게 진행해야 할지 잘 모르겠습니다. 어떤 도움이라도 대단히 감사하겠습니다!!! 감사합니다!


참조 솔루션

방법 1:

The input data is not a valid GeoJSON polygon.

From the spec [1]:

For type "Polygon", the "coordinates" member must be an array of LinearRing coordinate arrays.

So let's look at what a "LinearRing coordinate array" is [2]:

A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.

To make it short, the input data you mention here is missing one nested array in the coordinates field. The coordinates of a Polygon must be an array of arrays of coordinates. This is so that you can construct a polygon with holes in it (the first LinearRing in the Polygon is the outside edge, any subsequent LinearRings in the coordinates array will be considered holes).

The following should work:

{
    "feature": {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [
                    [
                        ‑71.17351189255714,
                        42.350224666504324
                    ],
                    [
                        ‑71.1677360907197,
                        42.34671571695422
                    ],
                    [
                        ‑71.16970919072628,
                        42.35326835618748
                    ],
                    [
                        ‑71.14341516047716,
                        42.36174674733808
                    ],
                    [
                        ‑71.17559093981981,
                        42.368232175909064
                    ],
                    [
                        ‑71.17351189255714,
                        42.350224666504324
                    ]
                ]
            ]
        },
        "properties": {}
    },
    "name": "New Polygon"
}

[1] http://geojson.org/geojson‑spec.html#polygon

[2] http://geojson.org/geojson‑spec.html#linestring

(by Robert LavertyDaniel Mewes)

참조 문서

  1. RethinkDB r.polygon() ‑ GeoJSON LinearRing must have at least four positions? (CC BY‑SA 2.5/3.0/4.0)

#geojson #rethinkdb #javascript #node.js #polygon






관련 질문

Geodjango GeoJSON 직렬 변환기 기하학은 항상 'null'입니다. (Geodjango GeoJSON Serializer geometry always 'null')

전단지에서 레이어 켜기/끄기(더 복잡한 시나리오) (Toggle layers on and off in Leaflet (more complex scenario))

RethinkDB r.polygon() - GeoJSON LinearRing에는 최소 4개의 위치가 있어야 합니까? (RethinkDB r.polygon() - GeoJSON LinearRing must have at least four positions?)

Leaflet : GeoJSON 속성에서 GeoJSON 레이어 설정 아이콘 (Leaflet : setting icon for GeoJSON layer from GeoJSON property)

'GeoJsonLayer' 기호를 확인할 수 없습니다. (Cannot resolve symbol 'GeoJsonLayer ')

스키마의 mongoose geojson, "지역 키를 추출할 수 없습니다" 오류 (mongoose geojson in schema, "Can't extract geo keys" error)

Android Google 지도는 GeoJSON을 사용하여 마커를 설정합니다. (Android Google Maps set marker using GeoJSON)

GraphQl로 geojson 포인트를 쿼리하는 방법은 무엇입니까? (How to query a geojson point with GraphQl?)

geojson 포인트 데이터 마커가 전단지 맵에서 클러스터링되지 않습니다. (The geojson point data markers are not clustering in leaflet map)

전단지 geoJSON.onEachFeature는 함수가 아닌가요? (leaflet geoJSON.onEachFeature is not a function?)

Folium에서 특정 국가 강조 표시 (Highlight one specific country in Folium)

RGeo 및 Geojson으로 면적 계산 (Calculating area with RGeo and Geojson)







코멘트