GeoJsonData QML Type
GeoJSON ドキュメントを表現、ロード、保存するモデル。詳細...
Import Statement: | import QtLocation 6.8 |
Since: | QtLocation 6.7 |
- 継承されたメンバを含む、全メンバのリスト
- GeoJsonData はQML Maps Plugin に含まれます。
プロパティ
方法
- 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 プロパティにバインドされます。ビューで項目を視覚化するには、Delegate を使用します。
GeoJSON については、GeoJSON のウェブサイトをご覧ください。
GeoJSON オブジェクト
GeoJSON オブジェクトは、ジオメトリ、フィーチャ、またはジオメトリやフィーチャのコレクションを表す有効な JSON オブジェクトです。
GeoJSON オブジェクトは、これらのタイプのいずれかでなければなりません:
Point
MultiPoint
LineString
MultiLineString
Polygon
MultiPolygon
GeometryCollection
Feature
FeatureCollection
型を設定するには、type
メンバを GeoJSON 型にバインドします。タイプを設定するには、QGeoShape メンバを GeoJSON タイプにバインドします。coordinates
メンバは、GeoJSON タイプに応じて、 またはリストのタイプになります。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仕様のポリゴンタイプを参照してください。例えば{ "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 オブジェクトは、2 つの平行でない線を構築します:{ "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 オブジェクトは、2 つの三角形のリストを含んでいます:{ "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
は、ジオメトリとプロパティ・メンバを持つ:
{ "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 Viewer の例では、GeoJsonData QML タイプを使って座標を読み込み、地図上に表示する方法を示しています。
プロパティの説明
model : QVariant |
GeoJSON ドキュメントのQVariant 表現。QML デリゲートはこの内容をビューに表示することができます。
このプロパティは Qt 6.7 で導入されました。
sourceUrl : QUrl |
GeoJSON ドキュメントの URL。このプロパティを設定すると、ドキュメントがロードされ、model メンバーにオブジェクトがバインドされます。
このプロパティは Qt 6.7 で導入されました。
メソッド ドキュメント
void clear() |
model にバインドされているすべてのアイテムを削除します。
void setModelToMapContents(MapView mapItemView) |
GeoJsonData オブジェクトのmodel にmapItemView のすべてのマップ項目を追加します。model から以前に格納されたマップ項目を削除します。
設定に成功した場合はtrue
を、失敗した場合はfalse
を返します。
addItemも参照のこと 。
© 2025 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.