wkt_parser 1.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • new80

WKT-PARSER-DART #

Wkt-parser-dart is the Dart version of proj4js/wkt-parser to convert a WKT CRS string into a Map<dynamic, dynamic> object.

Installing #

Add wkt_parser to pubspec.yml (dependencies section), then run pub get to download the new dependencies.

dependencies:
  wkt_parser: any # or the latest version on Pub

Using #

You can convert any OGC WKT / ESRI WKT definition string copied from epsg.io into a Map<dynamic,dynamic> format which then can be further converted into JSON to be fully interoperable with any programming languages. This example uses the OGC WKT of EPSG:23700.

import 'package:wkt_parser/wkt_parser.dart' as wkt_parser;

void main() {
  // WKT CRS string
  var wktText =
      'PROJCS["HD72 / EOV",GEOGCS["HD72",DATUM["Hungarian_Datum_1972",SPHEROID["GRS 1967",6378160,298.247167427,AUTHORITY["EPSG","7036"]],TOWGS84[52.17,-71.82,-14.9,0,0,0,0],AUTHORITY["EPSG","6237"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4237"]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["latitude_of_center",47.14439372222222],PARAMETER["longitude_of_center",19.04857177777778],PARAMETER["azimuth",90],PARAMETER["rectified_grid_angle",90],PARAMETER["scale_factor",0.99993],PARAMETER["false_easting",650000],PARAMETER["false_northing",200000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Y",EAST],AXIS["X",NORTH],AUTHORITY["EPSG","23700"]]';
  // Parsed object of type ProjWKT
  var output = wkt_parser.parseWKT(wktText);
  // This returns a JSON encoded string of the WKT
  print(output.toString());
}

The result should be (with JSON encode):

{
  "type": "PROJCS",
  "name": "HD72 / EOV",
  "GEOGCS": {
    "name": "HD72",
    "DATUM": {
      "name": "Hungarian_Datum_1972",
      "SPHEROID": {
        "name": "GRS 1967",
        "a": 6378160.0,
        "rf": 298.247167427,
        "AUTHORITY": {
          "EPSG": "7036"
        }
      },
      "TOWGS84": [52.17, -71.82, -14.9, 0.0, 0.0, 0.0, 0.0],
      "AUTHORITY": {
        "EPSG": "6237"
      }
    },
    "PRIMEM": {
      "name": "greenwich",
      "convert": 0.0,
      "AUTHORITY": {
        "EPSG": "8901"
      }
    },
    "UNIT": {
      "name": "degree",
      "convert": 0.0174532925199433,
      "AUTHORITY": {
        "EPSG": "9122"
      }
    },
    "AUTHORITY": {
      "EPSG": "4237"
    }
  },
  "PROJECTION": "Hotine_Oblique_Mercator_Azimuth_Center",
  "latitude_of_center": 47.14439372222222,
  "longitude_of_center": 19.04857177777778,
  "azimuth": 90.0,
  "rectified_grid_angle": 90.0,
  "scale_factor": 0.99993,
  "false_easting": 650000.0,
  "false_northing": 200000.0,
  "UNIT": {
    "name": "metre",
    "convert": 1.0,
    "AUTHORITY": {
      "EPSG": "9001"
    }
  },
  "AXIS": [
    ["Y", "EAST"],
    ["X", "NORTH"]
  ],
  "AUTHORITY": {
    "EPSG": "23700"
  },
  "projName": "Hotine_Oblique_Mercator_Azimuth_Center",
  "units": "meter",
  "to_meter": 1.0,
  "datumCode": "hungarian_datum_1972",
  "ellps": "GRS 1967",
  "a": 6378160.0,
  "rf": 298.247167427,
  "datum_params": [52.17, -71.82, -14.9, 0.0, 0.0, 0.0, 0.0],
  "k0": 0.99993,
  "lat0": 0.8228248943093227,
  "longc": 0.3324602953246919,
  "x0": 650000.0,
  "y0": 200000.0,
  "alpha": 1.5707963267948966,
  "srsCode": "HD72 / EOV"
}

Author #

Wkt-parser-dart was ported from proj4js/wkt-parser by Gergely Padányi-Gulyás (@fegyi001) at Ulyssys Ltd, Budapest, Hungary.

Changelog #

1.0.7 - 2020-03-20 #

  • Merge fix

1.0.6 - 2020-03-20 #

  • Rename example file for dart pub to find it

1.0.5 - 2020-03-20 #

  • Rename example file for dart pub to find it
  • Longer description for dart pub

1.0.4 - 2020-03-20 #

  • Fix in cleanWKT

1.0.3 - 2020-03-04 #

  • Add missing params to ProjWKT

1.0.2 - 2020-03-04 #

  • Rename WKT to ProjWKT
  • Rename parse() to parseWKT()

1.0.1 - 2020-03-03 #

  • Class WKT with static parse() method
  • Getters for WKT object parameters

1.0.0 - 2020-03-02 #

  • Initial version
  • It produces the same result as proj4js/wkt-parser for all the tests defined in proj4js/wkt-parser

example/main.dart

import 'package:wkt_parser/wkt_parser.dart' as wkt_parser;

void main() {
  // WKT CRS string
  var wktText =
      'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],AUTHORITY["EPSG","3857"]]';
  // Parsed object of type WKT
  var output = wkt_parser.parseWKT(wktText);
  // This returns a JSON encoded string of the WKT
  print(output.toString());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  wkt_parser: ^1.0.7

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:wkt_parser/wkt_parser.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Document public APIs. (-0.23 points)

37 out of 38 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.9.0
test ^1.14.2