GeoJsonData QML Type
GeoJSON 문서를 표현하고, 불러오고, 저장하는 모델입니다. 더 보기...
| Import Statement: | import QtLocation 6.12 |
| Since: | QtLocation 6.7 |
- 상속된 멤버를 포함한 모든 멤버 목록
- GeoJsonData는 QML Maps 플러그인의 일부입니다.
속성
방법
- bool addItem(Item item)
- void clear()
- bool open()
- bool openUrl(Url url)
- bool save()
- bool saveAs(Url url)
- void setModelToMapContents(MapView mapItemView)
상세 설명
GeoJsonData 유형은 GeoJSON 형식의 문서를 읽고 씁니다. GeoJsonData에는 sourceUrl 속성에 설정된 URL에서 모델을 열고 저장하는 기능이 있습니다. 로드된 모델은 내부적으로 QVariant 로 표현되며 model 속성에 바인딩됩니다. 델리게이트를 사용하여 뷰에서 항목을 시각화할 수 있습니다.
GeoJSON에 대한 자세한 내용은 GeoJSON 웹사이트를 참조하십시오.
GeoJSON 객체
GeoJSON 객체는 지오메트리, 피처 또는 지오메트리나 피처의 모음을 나타내는 유효한 JSON 객체입니다.
GeoJSON 객체는 다음 유형 중 하나여야 합니다.
PointMultiPointLineStringMultiLineStringPolygonMultiPolygonGeometryCollectionFeatureFeatureCollection
유형을 설정하려면 type 멤버를 GeoJSON 유형에 바인딩하십시오. coordinates 멤버는 GeoJSON 유형에 따라 QGeoShape 유형이거나 리스트일 수 있습니다. Feature 유형에는 geometry 및 properties 멤버가 추가로 있습니다.
기하형과 이에 상응하는 QVariant 표현의 목록:
Point객체의 경우, `coordinates`는 ` QGeoCircle`와 쌍을 이룹니다. 예를 들면 다음과 같습니다:{ "type": "Point", "coordinates": [11, 60] }이 GeoJSON 객체에는 다음과 같은 QVariantMap 표현이 대응됩니다:
{ type: "Point" coordinates: QGeoCircle({11.000, 60.000}, -1) }LineString객체의 경우,coordinates는 QGeoPath 와 짝을 이룹니다. 예를 들어:{ "type" : "LineString", "coordinates" : [ [13.5, 43], [10.73, 59.92] ] }이 GeoJSON 객체에는 이에 상응하는 QVariantMap 표현이 있습니다:
{ type : "LineString" data : QGeoPath([{43.000, 13.500}, {59.920, 10.730}]) }Polygon객체의 경우,coordinates멤버는 QGeoPolygon 과 쌍을 이룹니다(구멍이 있을 수 있음). 이 다각형은 선형 고리이며, 마지막 좌표가 첫 번째 좌표와 동일하여 고리가 열리고 닫힙니다.bbox멤버는 선택적 멤버로, 면적 범위를 설정하는 데 사용되며 오목한 경계를 정의할 때 유용합니다. 허용되는 다각형 좌표에 대한 자세한 내용은 GeoJSON 사양의 Polygon 유형을 참조하십시오. 예:{ "type": "Polygon", "coordinates": [ [ [17.13, 51.11], [30.54, 50.42], [26.70, 58.36], [17.13, 51.11] ] ], "bbox": [50, -50, 10, -10] }이 GeoJSON 객체는 다음과 같은 QVariantMap 표현을 가집니다:
{ type : "Polygon" coordinates : QGeoPolygon([{51.110, 17.130}, {50.420,30.540}, {58.360, 26.700}, {51.110, 17.130}]) }
MultiPoint, MultiLineString 및 MultiPolygon 유형의 경우, coordinates 는 QVariantList 와 짝을 이룹니다. 리스트 요소는 기하 정보를 포함하는 QVariantMap 입니다.
MultiPoint객체의 경우,coordinates은 Point 좌표 목록과 짝을 이룹니다. 예를 들어:{ "type": "MultiPoint", "coordinates": [ [11, 60], [5.5, 60.3], [5.7, 58.90] ] }이 GeoJSON 객체에는 이에 상응하는 QVariantMap 표현이 있습니다:
{ type : "MultiPoint" coordinates : [ { type : "Point" coordinates : QGeoCircle({60.000, 11.000}, -1) }, { type : "Point" coordinates : QGeoCircle({60.300, 5.500}, -1) }, { type : "Point" coordinates : QGeoCircle({58.900, 5.700}, -1) } ] }MultiLineString객체의 경우,coordinates는 LineString 좌표 목록과 쌍을 이룹니다. 다음 GeoJSON 객체는 두 개의 평행하지 않은 선분을 구성합니다:{ "type" : "MultiLineString", "coordinates" : [ [[13.5, 43], [10.73, 59.92]], [[9.15, 45], [-3.15, 58.90]] ] }이 GeoJSON 객체에는 이에 상응하는 QVariantMap 표현이 있습니다:
{ type : "MultiLineString" coordinates : [ { type : "LineString" coordinates : QGeoPath([{45.000, 9.150}, {58.900, -3.150}]) }, { type : "LineString" coordinates : QGeoPath([{43.000, 13.500}, {59.920, 10.730}]) } ] }MultiPolygon유형의 경우,coordinates는 Polygon 좌표 목록과 쌍을 이룹니다. 이 다각형은 선형 고리 형태이며,Polygon유형에서 허용되는 형식에 대한 자세한 정보를 확인할 수 있습니다. 다음 GeoJSON 객체에는 두 개의 삼각형 목록이 포함되어 있습니다:{ "type" : "MultiPolygon", "coordinates" : [ [ [[17.13, 51.11], [30.54, 50.42], [26.74, 58.36], [17.13, 51.11] ]], [ [[19.84, 41.33], [30.45, 49.26], [17.07, 50.10], [19.84, 41.33] ]] ] }이 GeoJSON 객체에 대응하는 QVariantMap 표현은 다음과 같습니다:
{ type : "MultiPolygon" coordinates : [ { type : "Polygon" coordinates : QGeoPolygon([{51.110, 17.130}, {50.420,30.540}, {58.360, 26.740}]) }, { type : "Polygon" coordinates : QGeoPolygon([{41.330, 19.840}, {49.260,30.450}, {50.100, 17.070}]) } ] }
GeometryCollection 유형은 다른 기하형들의 조합입니다. geometries 멤버의 값은 다른 GeometryCollection 유형을 포함하여 다양한 유형의 QVariantMap을 포함하는 QVariantList 입니다.
예를 들어, 다음 GeometryCollection 유형에는 여러 다른 지오메트리가 포함되어 있습니다:
{
"type" : "GeometryCollection",
"geometries" : [
{
"type" : "MultiPoint",
"coordinates" : [
[11,60], [5.5,60.3], [5.7,58.90]
]
},
{
"type" : "MultiLineString",
"coordinates": [
[[13.5, 43], [10.73, 59.92]],
[[9.15, 45], [-3.15, 58.90]]
]
},
{
"type" : "MultiPolygon",
"coordinates" : [
[
[
[17.13, 51.11],
[30.54, 50.42],
[26.74, 58.36],
[17.13, 51.11]
]
],
[
[
[19.84, 41.33],
[30.45, 49.26],
[17.07, 50.10],
[19.84, 41.33]
]
]
]
}
]
}이 GeoJSON 객체에는 이에 상응하는 QVariantMap 표현이 있습니다:
{
type : "GeometryCollection"
coordinates : [
{
type : "MultiPolygon"
coordinates : [
{
type : "Polygon"
coordinates : QGeoPolygon([{41.330, 19.840}, {49.260, 30.450}, {50.100, 17.070}])
},
{
type : "Polygon"
coordinates : QGeoPolygon([{51.110, 17.130}, {50.420, 30.540}, {58.360, 26.740}])
}
]
}
{
type : "MultiLineString"
coordinates : [
{
type : "LineString"
coordinates : QGeoPath([{45.000, 9.150}, {58.900, -3.150}])
},
{
type : "LineString"
coordinates : QGeoPath([{43.000, 13.500}, {59.920, 10.730}])
}
]
}
{
type : "MultiPoint"
coordinates : [
{
type : Point
coordinates : QGeoCircle({58.900, 5.700}, -1)
},
{
type : Point
coordinates : QGeoCircle({60.300, 5.500}, -1)
},
{
type : Point
coordinates : QGeoCircle({60.000, 11.000}, -1)
}
]
}
]
}Feature 유형에는 추가로 geometry 및 properties 멤버가 포함되어 있습니다. Feature 객체를 다른 기하 객체와 구별할 수 있는 유일한 방법은 QVariantMap 객체 내에 properties 노드가 존재하는지 확인하는 것입니다.
예를 들어, 다음 Feature 에는 geometry 및 properties 멤버가 있습니다:
{
"type": "Feature",
"id": "Poly",
"properties": {
"name": "Poly",
"text": "This is a Feature with a Polygon",
"color": "limegreen"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[17.13, 51.11],
[30.54, 50.42],
[26.70, 58.36],
[17.13, 51.11]
],
[
[23.46, 54.36],
[20.52, 51.91],
[28.25, 51.50],
[26.80, 54.36],
[23.46, 54.36]
]
]
}
}이 GeoJSON 객체는 다음과 같은 QVariantMap 표현을 가집니다:
{
type : "Polygon"
data : QGeoPolygon([{51.110, 17.130}, {50.420,30.540}, {58.360, 26.700}, {51.110, 17.130}])
properties : {text : "This is a Feature with a Polygon"}
}이 FeatureCollection 는 Feature 객체들의 조합입니다. ` features ` 멤버는 다른 Feature 객체들을 포함하는 ` QVariantList ` 객체에 바인딩됩니다.
예를 들어, 다음 FeatureCollection 에는 여러 Feature와 지오메트리가 포함되어 있습니다:
{
"type" : "FeatureCollection",
"properties" : {
"color" : "crimson"
},
"features" : [
{
"type" : "Feature",
"id" : "Poly",
"properties" : {
"text" : "This is a Feature with a Polygon"
},
"geometry" : {
"type" : "Polygon",
"coordinates" : [
[
[17.13, 51.11],
[30.54, 50.42],
[26.70, 58.36],
[17.13, 51.11]
],
[
[23.46, 54.36],
[20.52, 51.91],
[28.25, 51.50],
[26.80, 54.36],
[23.46, 54.36]
]
]
}
},
{
"type" : "Feature",
"id" : "MultiLine",
"properties" : {
"text" : "This is a Feature with a MultiLineString",
"color" : "deepskyblue"
},
"geometry" : {
"type" : "MultiLineString",
"coordinates" : [
[[13.5, 43], [10.73, 59.92]],
[[9.15, 45], [-3.15, 58.90]]
]
}
}
]
}이 GeoJSON 객체에는 이에 상응하는 QVariantMap 형식의 표현이 있습니다:
{
type: "FeatureCollection"
data: [{
type: "MultiLineString"
data: [{
type: "LineString"
data: QGeoPath( [{45.000, 9.150}, {58.900, -3.150}] )
} {
type: "LineString"
data: QGeoPath( [{43.000, 13.500}, {59.920, 10.730}] )
}]
properties: { text: "This is a Feature with a MultiLineString" }
},
{
type: "Polygon"
data: QGeoPolygon( {51.110, 17.130},
{50.420, 30.540},
{58.360, 26.700},
{51.110, 17.130}
)
properties: { text: "This is a Feature with a Polygon" }
}
]
}GeoJSON 예제
GeoJson 뷰어 예제는 GeoJsonData QML 유형을 사용하여 좌표를 불러오고 지도에 시각화하는 방법을 보여줍니다.
속성 문서
model : QVariant [since 6.7]
GeoJSON 문서를 QVariant 형식으로 표현한 것입니다. QML 델리게이트는 뷰에 해당 내용을 표시할 수 있습니다.
이 속성은 Qt 6.7에서 도입되었습니다.
sourceUrl : url [since 6.7]
GeoJSON 문서의 URL입니다. 이 속성을 설정하면 문서가 로드되고, 객체가 model 멤버에 바인딩됩니다.
이 속성은 Qt 6.7에서 도입되었습니다.
메서드 문서
bool addItem(Item item)
item 를 model 객체에 추가합니다.
추가에 성공하면 ` true `를 반환하고, 그렇지 않으면 ` false `를 반환합니다.
void clear()
model 에 바인딩된 모든 항목을 삭제합니다.
bool open()
sourceUrl 에 있는 파일의 내용을 불러옵니다.
파일 열기가 성공하면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.
bool openUrl(Url url)
url 에 있는 GeoJson 문서를 불러와 model 에 바인딩합니다. 파일 열기가 성공하면 sourceUrl 속성이 url 로 설정됩니다.
파일 열기가 성공하면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.
bool save()
모델을 sourceUrl 에 저장합니다.
저장이 성공하면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다.
bool saveAs(Url url)
model 를 url 에 저장합니다. 성공하면 sourceUrl 속성이 url 으로 설정됩니다.
저장이 성공하면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.
void setModelToMapContents(MapView mapItemView)
mapItemView 의 모든 맵 항목을 GeoJsonData 객체의 model 에 추가합니다. model 에서 이전에 저장된 맵 항목을 삭제합니다.
설정이 성공하면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다.
addItem도 참조하십시오 .
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.