Skip to content

Command line tool importing the Content Model of bathymetric-cam to Contentful.

License

Notifications You must be signed in to change notification settings

bathymetric-cam/contentful-geojson-uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bathymetric-cam-contentful

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

Quick Start

  1. Install via yarn
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

CONTENTFUL_ENVIRONMENT="master"
CONTENTFUL_MANAGEMENT_TOKEN="YOUR_MANAGEMENT_TOKEN"
CONTENTFUL_SPACE_ID="YOUR_SPACE_ID"

export-config.json

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

Create the following Content Model on Contentful dashboard.

- Name
bathymetry

- Fields
zoom: Integer
x: Integer
y: Integer
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.

{
  "entries": [
    {
      "fields": {
        "zoom": {
          "en-US": 16
        },
        "x": {
          "en-US": 57500
        },
        "y": {
          "en-US": 25955
        },
        "geoJSON": {
          "en-US": {
            "type": "FeatureCollection",
            "features": [
              { "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 ] ] ] ] } },
              { "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 ] ] ] ] } }
            ]
          }
        }
      }
    }
  ]
}

Then run the command.

yarn contentful:import
  1. Export imported contents

To see the imported contents, run the command below.

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.

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.

{
  "type": "FeatureCollection",
  "features": [
    { "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 ] ] ] ] } },
    { "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 ] ] ] ] } }
  ]
}

About

Command line tool importing the Content Model of bathymetric-cam to Contentful.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published