码迷,mamicode.com
首页 > Web开发 > 详细

GeoJson学习记录

时间:2015-01-15 16:11:33      阅读:549      评论:0      收藏:0      [点我收藏+]

标签:geojson

最近需要使用GeoJson来做传输交换格式,查了下资料。

  1. 官方网址; http://geojson.org/geojson-spec.html
  2. GeoJson支持点、线、面、多点、多线、多面、对象集合、记录、记录集合这几种类型,每一个GeoJson对象都一个类型成员。其中前六种为单一的空间对象类型。
    1. 点:[100.0,0.0]
    2. 点串: [ [100.0,0.0], [101.0,1.0] ]
    3. 多个点串:[点串1, 点串2]
    4. 对象:{"type":,  "coordinates": }
      1. 点对象:{ "type": "Point","coordinates":}
      2. 线对象:{ "type": "LineString","coordinates":点串 }
      3. 面对象:{"type": "Polygon", "coordinates": [点串1, 点串2] }
      4. 多点对象:{"type": "MultiPoint","coordinates": 点串 }
      5. 多线对象:{"type": "MultiLineString", "coordinates": [点串1, 点串2] }
      6. 多面对象:{"type": "MultiPolygon", "coordinates": [多个点串1, 多个点串2] }
    5. 对象集合:
       { "type": "GeometryCollection",
          "geometries": [
           对象1, 对象2
          ]
        }
    6. 记录:     
               { "type":"Feature",
              "geometry": 对象,
              "properties": {
                "prop0": "value0",
                "prop1": 0.0
                }
              }
    7. 记录集合:
      { "type": "FeatureCollection",
          "features": [
           记录1, 记录2
          ]
        }
  3. 空间对象有一个 点串成员来记录空间坐标。
  4. 每一个GeoJson对象可以有 坐标系、对象范围(感觉是对象的Bounds)两个成员。
  5. 例子:
    1.   { "type":"Point", "coordinates":[100.0, 0.0] }
    2. { "type":"LineString",
          "coordinates": [ [100.0,0.0], [101.0,1.0] ]
          }
    3.   { "type":"Polygon",
          "coordinates": [
            [ [100.0,0.0], [101.0,0.0], [101.0,1.0], [100.0,1.0], [100.0,0.0] ]
            ]
         }
    4.   { "type": "MultiPoint",
          "coordinates": [ [100.0,0.0], [101.0,1.0] ]
          }
    5. {"type": "MultiLineString",
          "coordinates": [
              [ [100.0,0.0], [101.0,1.0] ],
              [ [102.0,2.0], [103.0,3.0] ]
            ]
          }
    6.  {"type": "MultiPolygon",
          "coordinates": [
            [[[102.0,2.0], [103.0,2.0], [103.0,3.0], [102.0,3.0], [102.0,2.0]]],
            [[[100.0,0.0], [101.0,0.0], [101.0,1.0], [100.0,1.0], [100.0,0.0]],
             [[100.2,0.2], [100.8,0.2], [100.8,0.8], [100.2,0.8], [100.2,0.2]]]
            ]
          }
    7.  { "type": "GeometryCollection",
          "geometries": [
            { "type":"Point",
              "coordinates": [100.0, 0.0]
              },
            { "type":"LineString",
              "coordinates": [ [101.0,0.0], [102.0,1.0] ]
              }
          ]
        }
    8.      { "type": "Feature",
              "geometry": { "type": "LineString",
                "coordinates": [
                  [102.0,0.0], [103.0,1.0], [104.0,0.0], [105.0,1.0]
                  ]
                },
              "properties": {
                "prop0": "value0",
                "prop1": 0.0
                }
              }
    9.  { "type": "FeatureCollection",
          "features": [
            { "type":"Feature",
              "geometry": {"type": "Point","coordinates": [102.0,0.5]},
              "properties": {"prop0": "value0"}
              },
            { "type":"Feature",
              "geometry": {
                "type": "LineString",
                "coordinates": [
                  [102.0,0.0], [103.0,1.0], [104.0,0.0], [105.0,1.0]
                  ]
                },
              "properties": {
                "prop0": "value0",
                "prop1": 0.0
                }
              },
            { "type":"Feature",
               "geometry": {
                 "type": "Polygon",
                 "coordinates": [
                   [ [100.0,0.0], [101.0,0.0], [101.0,1.0],
                     [100.0,1.0], [100.0,0.0] ]
                   ]
               },
               "properties": {
                 "prop0": "value0",
                 "prop1": {"this": "that"}
                 }
               }
             ]
           }

转载请注明出处: http://write.blog.csdn.net/postedit/42741097 qianjn




GeoJson学习记录

标签:geojson

原文地址:http://blog.csdn.net/tianlanzhijing/article/details/42741097

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!