0.0.0 • Published 2 years ago

shapefile-mapjson-converter-js v0.0.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Shapefile to MapJson Converter

Shapefile-Mapjson-Converter-JS is an Angular based library to support the guided shape import in FendtONE. It can be used to convert shape data (*.zip) into MapJson for presenting the field boundaries of the import on a map so that the user can decide whether the import is correct or not. This project is just about converting the data and does not contain any UI components. The presentation to the user is then the responsibility of FendtONE.

More details can be found in the ONE Digital wiki here.

MapJson

MapJson is a JSON based format defined by AGCO to display field boundaries on a map in FendtONE.

Example:

[
	[
		{
			"name": "Field1",
			"coordinates": [
				{
					"lat": 47.775,
					"lng": 10.613
				},
				{
					"lat": 47.77501,
					"lng": 10.613
				},
                                ...
			]
		}
	],
	[
		{
			"name": "Field2",
			"coordinates": [
				{
					"lat": 47.775,
					"lng": 10.61313
				},
				{
					"lat": 47.77501,
					"lng": 10.61313
				},
                                ...
			]
		}
	],
        ...
]

Usage

To use the library in your project you need to add the AGCO npm registry to your configuration.

npm config set @agcocorp:registry https://artifactory.agco-fuse-services.com/artifactory/api/npm/npm-virtual/

There are two ways to authenticate your npm client against Artifactory: using the npm login command or using basic authentication.

Using npm login
Run the following command in your npm client. When prompted, provide your Artifactory login credentials:

npm login

Using basic authentication
Alternatively, you can paste the following into the ~/.npmrc file (in Windows %USERPROFILE%/.npmrc):

_auth = <USERNAME>:<PASSWORD> (converted to base 64)
email = youremail@email.com
always-auth = true

If you are working with scoped packages, while using basic authentication, you also need to paste the following into the ~/.npmrc file (in Windows %USERPROFILE%/.npmrc):

@agcocorp:registry=https://artifactory.agco-fuse-services.com/artifactory/api/npm/npm-virtual/
//artifactory.agco-fuse-services.com/artifactory/api/npm/npm-virtual/:_password=<BASE64_PASSWORD>
//artifactory.agco-fuse-services.com/artifactory/api/npm/npm-virtual/:username=<USERNAME>
//artifactory.agco-fuse-services.com/artifactory/api/npm/npm-virtual/:email=youremail@email.com
//artifactory.agco-fuse-services.com/artifactory/api/npm/npm-virtual/:always-auth=true

Development Instructions

The repository contains two projects. One is the actual library (shapefile-mapjson-converter-js) and the other one is an example project (shapefile-mapjson-converter-example-app) that should illustrate how to use the library.

Build the library

Run npm install --legacy-peer-deps to install all dependencies.
Run ng build shapefile-mapjson-converter-js to build the shapefile-mapjson-converter-js library.

Publish the library

Run ng publish .\dist\shapefile-mapjson-converter-js\ --registry https://artifactory.agco-fuse-services.com/artifactory/api/ npm/npm-local/ to publish the shapefile-mapjson-converter-js library to artifactory.

Run the example

To use the example and show the map a Google-Maps API key is needed. So before running the example it is necessary to set the Google-Maps API Key

projects/shapefile-mapjson-converter-example-app/src/app/app.module.ts:

    AgmCoreModule.forRoot({
      apiKey: 'set googlemaps api key here'
    })

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.