Coder Social home page Coder Social logo

simple-features-js's Introduction

Simple Features Javascript

Simple Features Lib

The Simple Features Libraries were developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with BIT Systems. The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the MIT license.

Pull Requests

If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.

Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license.

About

Simple Features is a Javascript library of geometry objects and utilities based upon the OGC Simple Feature Access standard.

Simple Feature Conversion Libraries

Usage

View the latest JS Docs

Browser Usage

<script src="/path/to/simple-features-js/dist/sf.min.js"></script>
const { Point, LineString, Polygon } = window.SimpleFeatures;

const point = new Point(0, 0);
const lineString = new LineString(point);
const polygon = new Polygon(lineString)

Node Usage

NPM

Pull from NPM

npm install --save simple-features-js
const { Point, LineString, Polygon } = require("@ngageoint/simple-features-js");

const point = new Point(0, 0);
const lineString = new LineString(point);
const polygon = new Polygon(lineString)

Build

Build & Test

Build this repository using Node.js:

npm install
npm run build

simple-features-js's People

Contributors

caldwellc avatar gillandk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

dewars-org

simple-features-js's Issues

The `js_cols` dependency breaks modern setups

Problem

This library is not functional out of the box when using a modern setup like vite v5 and typescript v5 which impacts @ngageoint/grid-js and @ngageoint/mgrs-js usage. It looks like the js_cols dependency is improperly bundled which blows up on "Uncaught ReferenceError: js_cols is not defined"

I'm unsure why exactly this works in commonjs vs es modules + vite. Regardless, js_cols does not have a very robust bundle (see https://github.com/thomasstjerne/js_cols/blob/master/dist/js_cols.min.js).

Ideal Solution

Shim or fix js_cols so that downstream users of libraries like @ngageoint/mgrs-js don't have to.

Steps to Reproduce

  1. Generate vite project i.e. npm create vite@latest my-app -- --template vanilla-ts
  2. Add the following to the index.html in the body tag
        <script type="module">
          import * as gridJs from '@ngageoint/grid-js';
          import * as mgrsJs from '@ngageoint/mgrs-js';
          console.log(mgrsJs.MGRS.from(gridJs.Point.degrees(0, 0)));
        </script>

Temp Workaround

See below for my temp temp solution. This defines the js_cols variable on global scope. It's later overridden when the library is imported.

        <script type="module">
          // This goes before the main bundle in the body
          window.js_cols = undefined;
        </script>

Environment

  • vite v5
  • node v20
  • typescript v5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.