项目作者: bathymetric-cam

项目描述 :
Command line tool importing the Content Model of bathymetric-cam to Contentful.
高级语言: TypeScript
项目地址: git://github.com/bathymetric-cam/bathymetric-cam-contentful.git
创建时间: 2021-01-14T08:21:23Z
项目社区:https://github.com/bathymetric-cam/bathymetric-cam-contentful

开源协议:MIT License

下载


bathymetric-cam-contentful

bathymetric-cam-contentful is a tool importing the Content Model of bathymetric-cam to Contentful.

Quick Start

  1. Install via yarn
  1. yarn install
  1. Make .env and export-config.json

Create your account and a Space on Contentful.
Then make the following files on the top-level directory.

.env

  1. CONTENTFUL_ENVIRONMENT="master"
  2. CONTENTFUL_MANAGEMENT_TOKEN="YOUR_MANAGEMENT_TOKEN"
  3. CONTENTFUL_SPACE_ID="YOUR_SPACE_ID"

export-config.json

  1. {
  2. "managementToken": "YOUR_MANAGEMENT_TOKEN",
  3. "spaceId": "YOUR_SPACE_ID"
  4. }
  1. Create a Content Model

Create the following Content Model on Contentful dashboard.

  1. - Name
  2. bathymetry
  3. - Fields
  4. zoom: Integer
  5. x: Integer
  6. y: Integer
  7. geoJSON: JSON Object
  1. Import Contentful Content

Create content.json on the top-level directory.
entries key’s value is the array of bathymetry contents you upload.

An example of content.json.

  1. {
  2. "entries": [
  3. {
  4. "fields": {
  5. "zoom": {
  6. "en-US": 16
  7. },
  8. "x": {
  9. "en-US": 57500
  10. },
  11. "y": {
  12. "en-US": 25955
  13. },
  14. "geoJSON": {
  15. "en-US": {
  16. "type": "FeatureCollection",
  17. "features": [
  18. { "type": "Feature", "properties": { "maxDepth": 2.0, "minDepth": 1.5 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 135.862440443284839, 35.014492927129652 ], [ 135.861566355907911, 35.013989812325164 ], [ 135.861452697487437, 35.013956566744483 ], [ 135.86136880674843, 35.013956566744483 ], [ 135.861263266786551, 35.013969864978385 ], [ 135.861219968340606, 35.014027490633616 ], [ 135.861663777411223, 35.014293454669961 ], [ 135.861669189716991, 35.014357729182343 ], [ 135.861631303576814, 35.01443086908322 ], [ 135.861577180519419, 35.014477412622462 ], [ 135.861506820544804, 35.014490710771689 ], [ 135.8613958682771, 35.014497359845464 ], [ 135.861274091397974, 35.014486278055521 ], [ 135.861471640557511, 35.01460596130751 ], [ 135.8615609436022, 35.014670235574265 ], [ 135.861655658952628, 35.014727860736002 ], [ 135.861828852736295, 35.014834245543291 ], [ 135.861993928061366, 35.01492289944364 ], [ 135.862072406494576, 35.014927332136132 ], [ 135.862145472622046, 35.014947279249384 ], [ 135.862004752672817, 35.014838678240586 ], [ 135.861907331169505, 35.014725644384384 ], [ 135.861826146583411, 35.014628124853488 ], [ 135.86178014198461, 35.014521739778075 ], [ 135.861785554290378, 35.014453032676663 ], [ 135.861834265042063, 35.014410921844018 ], [ 135.861945217309682, 35.014406489123537 ], [ 135.862110292634725, 35.014472979905584 ], [ 135.862297017182726, 35.014532821563215 ], [ 135.862432324826244, 35.014597095887453 ], [ 135.862440443284839, 35.014492927129652 ] ] ] ] } },
  19. { "type": "Feature", "properties": { "maxDepth": 3.0, "minDepth": 2.5 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 135.860924997677785, 35.014269074669315 ], [ 135.861073836085666, 35.014096198092524 ], [ 135.861144196060309, 35.014105063566895 ], [ 135.861390455971446, 35.014251343755184 ], [ 135.861425635958739, 35.014320051026054 ], [ 135.861422929805855, 35.014388758239207 ], [ 135.86135798213698, 35.014404272763215 ], [ 135.861284916009481, 35.014402056402815 ], [ 135.861163139130383, 35.014377676434535 ], [ 135.860924997677785, 35.014269074669315 ] ] ] ] } }
  20. ]
  21. }
  22. }
  23. }
  24. }
  25. ]
  26. }

Then run the command.

  1. yarn contentful:import
  1. Export imported contents

To see the imported contents, run the command below.

  1. yarn contentful:export
  1. Convert geojson into content.json

To convert geojson into content.json, place geojson files in geojson folder and run the following command.

  1. yarn convert

Make sure the geojson file name is the format like ${zoom_level}.${x}.${y}.geojson.
The zoom_level, x, and y are based on the tile system.

  1. {
  2. "type": "FeatureCollection",
  3. "features": [
  4. { "type": "Feature", "properties": { "maxDepth": 2.0, "minDepth": 1.5 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 135.862440443284839, 35.014492927129652 ], [ 135.861566355907911, 35.013989812325164 ], [ 135.861452697487437, 35.013956566744483 ], [ 135.86136880674843, 35.013956566744483 ], [ 135.861263266786551, 35.013969864978385 ], [ 135.861219968340606, 35.014027490633616 ], [ 135.861663777411223, 35.014293454669961 ], [ 135.861669189716991, 35.014357729182343 ], [ 135.861631303576814, 35.01443086908322 ], [ 135.861577180519419, 35.014477412622462 ], [ 135.861506820544804, 35.014490710771689 ], [ 135.8613958682771, 35.014497359845464 ], [ 135.861274091397974, 35.014486278055521 ], [ 135.861471640557511, 35.01460596130751 ], [ 135.8615609436022, 35.014670235574265 ], [ 135.861655658952628, 35.014727860736002 ], [ 135.861828852736295, 35.014834245543291 ], [ 135.861993928061366, 35.01492289944364 ], [ 135.862072406494576, 35.014927332136132 ], [ 135.862145472622046, 35.014947279249384 ], [ 135.862004752672817, 35.014838678240586 ], [ 135.861907331169505, 35.014725644384384 ], [ 135.861826146583411, 35.014628124853488 ], [ 135.86178014198461, 35.014521739778075 ], [ 135.861785554290378, 35.014453032676663 ], [ 135.861834265042063, 35.014410921844018 ], [ 135.861945217309682, 35.014406489123537 ], [ 135.862110292634725, 35.014472979905584 ], [ 135.862297017182726, 35.014532821563215 ], [ 135.862432324826244, 35.014597095887453 ], [ 135.862440443284839, 35.014492927129652 ] ] ] ] } },
  5. { "type": "Feature", "properties": { "maxDepth": 3.0, "minDepth": 2.5 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 135.860924997677785, 35.014269074669315 ], [ 135.861073836085666, 35.014096198092524 ], [ 135.861144196060309, 35.014105063566895 ], [ 135.861390455971446, 35.014251343755184 ], [ 135.861425635958739, 35.014320051026054 ], [ 135.861422929805855, 35.014388758239207 ], [ 135.86135798213698, 35.014404272763215 ], [ 135.861284916009481, 35.014402056402815 ], [ 135.861163139130383, 35.014377676434535 ], [ 135.860924997677785, 35.014269074669315 ] ] ] ] } }
  6. ]
  7. }