Skip to content

Commit

Permalink
#build-patch: default precision set to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
reskume committed Dec 4, 2024
1 parent 938f51d commit 40f7b6e
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 183 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { DecimalUnsignedFormat } from '@openaip/openaip-coordinate-parser/format

// only parsing two formats is ever required
const decimalParser = new DecimalUnsignedFormat({ precision: 5 });
const decimalSexaParser = new DecimalSignedFormat({ precision: 3 });
const decimalSexaParser = new DecimalSignedFormat({ precision: 5 });
// only use two parsers instead of all default ones
const parser = new Parser({ formatParsers: [decimalParser, decimalSexaParser] });

Expand Down
2 changes: 1 addition & 1 deletion src/formats/base-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class BaseFormat implements IFormatParser {
constructor(options?: Config) {
validateSchema(options, OptionsSchema, { assert: true, name: 'config' });

const defaultOptions = { precision: 3 };
const defaultOptions = { precision: 5 };
const { precision } = { ...defaultOptions, ...options };

this.precision = precision;
Expand Down
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Parser {
validateSchema(options, OptionsSchema, { assert: true, name: 'options' });

const defaultOptions = {
precision: 3,
precision: 5,
extendFormatParsers: false,
};
const { precision, extendFormatParsers } = { ...defaultOptions, ...options };
Expand Down
16 changes: 8 additions & 8 deletions tests/dm-unsigned-prefixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ describe('parse', () => {
it("returns the correct latitude and longitude for 'N4007 W7407'", () => {
const formatParser = new DmUnsignedPrefixedHemisphereFormat();
const result = formatParser.parse('N4007 W7407');
expect(result.latitude).toBe(40.117);
expect(result.longitude).toBe(-74.117);
expect(result.latitude).toBe(40.11667);
expect(result.longitude).toBe(-74.11667);
});

it("returns the correct latitude and longitude for 'N4007.38W7407.38'", () => {
const formatParser = new DmUnsignedPrefixedHemisphereFormat();
const result = formatParser.parse('N4007.38W7407.38');
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it("returns the correct latitude and longitude for 'N 4007.38 W 7407.38'", () => {
const formatParser = new DmUnsignedPrefixedHemisphereFormat();
const result = formatParser.parse('N 4007.38 W 7407.38');
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it("returns the correct latitude and longitude for 'N4007.38 W7407.38'", () => {
const formatParser = new DmUnsignedPrefixedHemisphereFormat();
const result = formatParser.parse('N4007.38 W7407.38');
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});
});
16 changes: 8 additions & 8 deletions tests/dm-unsigned-suffixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ describe('parse', () => {
it("returns the correct latitude and longitude for '4007N 7407W'", () => {
const formatParser = new DmUnsignedSuffixedHemisphereFormat();
const result = formatParser.parse('4007N 7407W');
expect(result.latitude).toBe(40.117);
expect(result.longitude).toBe(-74.117);
expect(result.latitude).toBe(40.11667);
expect(result.longitude).toBe(-74.11667);
});

it("returns the correct latitude and longitude for '4007.38N 7407.38W'", () => {
const formatParser = new DmUnsignedSuffixedHemisphereFormat();
const result = formatParser.parse('4007.38N 7407.38W');
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it("returns the correct latitude and longitude for '4007.38N7407.38W'", () => {
const formatParser = new DmUnsignedSuffixedHemisphereFormat();
const result = formatParser.parse('4007.38N7407.38W');
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it("returns the correct latitude and longitude for '4007.38 N 7407.38 W'", () => {
const formatParser = new DmUnsignedSuffixedHemisphereFormat();
const result = formatParser.parse('4007.38 N 7407.38 W');
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});
});
12 changes: 6 additions & 6 deletions tests/dms-block-prefixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for N400723 W0740723`, () => {
const formatParser = new DmsBlockPrefixedHemisphereFormat();
const result = formatParser.parse(`N400723 W0740723`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N400723W0740723`, () => {
const formatParser = new DmsBlockPrefixedHemisphereFormat();
const result = formatParser.parse(`N400723W0740723`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N400723, W0740723`, () => {
const formatParser = new DmsBlockPrefixedHemisphereFormat();
const result = formatParser.parse(`N400723, W0740723`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N400723.999, W0740723.999`, () => {
Expand Down
12 changes: 6 additions & 6 deletions tests/dms-block-suffixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for 400723N 0740723W`, () => {
const formatParser = new DmsBlockSuffixedHemisphereFormat();
const result = formatParser.parse(`400723N 0740723W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 400723N0740723W`, () => {
const formatParser = new DmsBlockSuffixedHemisphereFormat();
const result = formatParser.parse(`400723N0740723W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 400723N, 0740723W`, () => {
const formatParser = new DmsBlockSuffixedHemisphereFormat();
const result = formatParser.parse(`400723N, 0740723W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 400723.999N, 0740723.999W`, () => {
Expand Down
20 changes: 10 additions & 10 deletions tests/dms-signed-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for 40°7'23" -74°7'23"`, () => {
const formatParser = new DmsSignedFormat();
const result = formatParser.parse(`40°7'23" -74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40°7'23", -74°7'23"`, () => {
const formatParser = new DmsSignedFormat();
const result = formatParser.parse(`40°7'23", -74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40°7'23",-74°7'23"`, () => {
const formatParser = new DmsSignedFormat();
const result = formatParser.parse(`40°7'23",-74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40° 7' 23" -74° 7' 23"`, () => {
const formatParser = new DmsSignedFormat();
const result = formatParser.parse(`40° 7' 23" -74° 7' 23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40° 7' 23", -74° 7' 23"`, () => {
const formatParser = new DmsSignedFormat();
const result = formatParser.parse(`40° 7' 23", -74° 7' 23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40° 7' 23.9999", -74° 7' 23.9999"`, () => {
Expand Down
24 changes: 12 additions & 12 deletions tests/dms-signed-prefixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,43 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for N40°7'23" W74°7'23"`, () => {
const formatParser = new DmsSignedPrefixedHemisphereFormat();
const result = formatParser.parse(`N40°7'23" W74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40°7'23"W74°7'23"`, () => {
const formatParser = new DmsSignedPrefixedHemisphereFormat();
const result = formatParser.parse(`N40°7'23"W74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N 40° 7' 23" W 74° 7' 23"`, () => {
const formatParser = new DmsSignedPrefixedHemisphereFormat();
const result = formatParser.parse(`N 40° 7' 23" W 74° 7' 23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40°7'23", W74°7'23"`, () => {
const formatParser = new DmsSignedPrefixedHemisphereFormat();
const result = formatParser.parse(`N40°7'23", W74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40°7'23",W74°7'23"`, () => {
const formatParser = new DmsSignedPrefixedHemisphereFormat();
const result = formatParser.parse(`N40°7'23",W74°7'23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40° 7' 23", W74° 7' 23"`, () => {
const formatParser = new DmsSignedPrefixedHemisphereFormat();
const result = formatParser.parse(`N40° 7' 23", W74° 7' 23"`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N 40° 7' 23.9999", W 74° 7' 23.9999"`, () => {
Expand Down
12 changes: 6 additions & 6 deletions tests/dms-unsigned-delimited-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for 40:7:23 -74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedFormat();
const result = formatParser.parse(`40:7:23 -74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23, -74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedFormat();
const result = formatParser.parse(`40:7:23, -74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23,-74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedFormat();
const result = formatParser.parse(`40:7:23,-74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23.9999", -74:7:23.9999`, () => {
Expand Down
20 changes: 10 additions & 10 deletions tests/dms-unsigned-delimited-prefixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for N40:7:23 W74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedPrefixedHemisphere();
const result = formatParser.parse(`N40:7:23 W74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40:7:23W74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedPrefixedHemisphere();
const result = formatParser.parse(`N40:7:23W74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40:7:23 W74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedPrefixedHemisphere();
const result = formatParser.parse(`N40:7:23 W74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40:7:23, W74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedPrefixedHemisphere();
const result = formatParser.parse(`N40:7:23, W74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N40:7:23,W74:7:23`, () => {
const formatParser = new DmsUnsignedDelimitedPrefixedHemisphere();
const result = formatParser.parse(`N40:7:23,W74:7:23`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for N 40:7:23.9999, W 74:7:23.9999`, () => {
Expand Down
16 changes: 8 additions & 8 deletions tests/dms-unsigned-delimited-suffixed-hemisphere-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ describe('parse', () => {
it(`returns the correct latitude and longitude for 40:7:23N 74:7:23W`, () => {
const formatParser = new DmsUnsignedDelimitedSuffixedHemisphereFormat();
const result = formatParser.parse(`40:7:23N 74:7:23W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23N74:7:23W`, () => {
const formatParser = new DmsUnsignedDelimitedSuffixedHemisphereFormat();
const result = formatParser.parse(`40:7:23N74:7:23W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23N, 74:7:23W`, () => {
const formatParser = new DmsUnsignedDelimitedSuffixedHemisphereFormat();
const result = formatParser.parse(`40:7:23N, 74:7:23W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23N,74:7:23W`, () => {
const formatParser = new DmsUnsignedDelimitedSuffixedHemisphereFormat();
const result = formatParser.parse(`40:7:23N,74:7:23W`);
expect(result.latitude).toBe(40.123);
expect(result.longitude).toBe(-74.123);
expect(result.latitude).toBe(40.12306);
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 40:7:23.9999N, 74:7:23.9999W`, () => {
Expand Down
Loading

0 comments on commit 40f7b6e

Please sign in to comment.