1.2.2 • Published 6 months ago

geojsonwkt v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago
方法示例
geojson 转 wkt 适用于二维坐标转换
import geofuns from 'geojsonwkt';
const { geojsonToWkt } = geofuns;
const geojson = {
  type: 'Polygon',
  coordinates: [
    [
      [100.0, 0.0],
      [101.0, 0.0],
      [101.0, 1.0],
      [100.0, 1.0],
      [100.0, 0.0],
    ],
  ],
};
const geojson1 = {
  type: 'Feature',
  geometry: {
    type: 'Polygon',
    coordinates: [
      [
        [100, 0],
        [101, 0],
        [101, 1],
        [100, 1],
        [100, 0],
      ],
    ],
  },
};
const wkt = geojsonToWkt(geojson); // POLYGON((100 0,101 0,101 1,100 1,100 0))
const wkt1 = geojsonToWkt(geojson1); // POLYGON((100 0,101 0,101 1,100 1,100 0))
wkt 转 geojson
import geofuns from 'geojsonwkt';
const { wktToGeojson } = geofuns;
const wkt = 'POLYGON((100 0,101 0,101 1,100 1,100 0))';
const geojson = wktToGeojson(wkt); // {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[100,0],[101,0],[101,1],[100,1],[100,0]]]}}
生成中国范围内的遮罩
import geofuns from 'geojsonwkt';
const { createMaskPolygon } = geofuns;
const geojson = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: {},
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [107.220598, 38.59126],
            [111.695778, 36.165477],
            [111.068417, 34.044305],
            [106.133171, 35.521318],
            [107.220598, 38.59126],
          ],
        ],
      },
    },
    {
      type: 'Feature',
      properties: {},
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [107.366982, 32.028421],
            [107.366982, 34.459151],
            [115.418125, 34.459151],
            [115.418125, 32.028421],
            [107.366982, 32.028421],
          ],
        ],
      },
    },
  ],
};
const mask = createMaskPolygon(geojson);
/* {
    "type": "Feature",
    "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [73,3],
              [136,3],
              [136,54],
              [73,54],
              [73,3]
            ],
            [
              [106.133171,35.521318],
              [109.68226328157235,34.459151],
              [107.366982,34.459151],
              [107.366982,32.028421],
              [115.418125,32.028421],
              [115.418125,34.459151],
              [111.19111247278863,34.459151],
              [111.695778,36.165477],
              [107.220598,38.59126],
              [106.133171,35.521318]
            ]
          ]
        ]
    },
    "properties": {}
}*/
1.2.0

6 months ago

1.2.2

6 months ago

1.2.1

6 months ago

1.1.10

8 months ago

1.1.9

9 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

12 months ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago