@pgpm/geotypes 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/Makefile +6 -0
- package/README.md +5 -0
- package/__tests__/geotypes.test.ts +55 -0
- package/deploy/schemas/public/domains/geolocation.sql +10 -0
- package/deploy/schemas/public/domains/geopolygon.sql +10 -0
- package/deploy/schemas/public/schema.sql +2 -0
- package/jest.config.js +15 -0
- package/launchql-geo-types.control +8 -0
- package/launchql.plan +7 -0
- package/package.json +29 -0
- package/revert/schemas/public/domains/geolocation.sql +7 -0
- package/revert/schemas/public/domains/geopolygon.sql +7 -0
- package/revert/schemas/public/schema.sql +1 -0
- package/sql/launchql-geo-types--0.4.6.sql +8 -0
- package/verify/schemas/public/domains/geolocation.sql +7 -0
- package/verify/schemas/public/domains/geopolygon.sql +7 -0
- package/verify/schemas/public/schema.sql +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
|
|
4
|
+
Copyright (c) 2025 Interweb, Inc.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/Makefile
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getConnections, PgTestClient } from 'pgsql-test';
|
|
2
|
+
|
|
3
|
+
jest.setTimeout(15000);
|
|
4
|
+
|
|
5
|
+
let pg: PgTestClient;
|
|
6
|
+
let teardown: () => Promise<void>;
|
|
7
|
+
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
({ pg, teardown } = await getConnections());
|
|
10
|
+
|
|
11
|
+
await pg.any(`
|
|
12
|
+
CREATE TABLE places (
|
|
13
|
+
id serial PRIMARY KEY,
|
|
14
|
+
loc geolocation,
|
|
15
|
+
area geopolygon
|
|
16
|
+
);
|
|
17
|
+
`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterAll(async () => {
|
|
21
|
+
await teardown();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('places table (geotypes)', () => {
|
|
25
|
+
it('inserts valid point and polygon', async () => {
|
|
26
|
+
await expect(pg.any(`
|
|
27
|
+
INSERT INTO places (loc, area)
|
|
28
|
+
VALUES (
|
|
29
|
+
ST_SetSRID(ST_MakePoint(-122.4194, 37.7749), 4326),
|
|
30
|
+
ST_SetSRID(
|
|
31
|
+
ST_GeomFromText('POLYGON((-122.5 37.7, -122.4 37.7, -122.4 37.8, -122.5 37.8, -122.5 37.7))'),
|
|
32
|
+
4326
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
`)).resolves.not.toThrow();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('fails if point SRID is incorrect', async () => {
|
|
39
|
+
await expect(pg.any(`
|
|
40
|
+
INSERT INTO places (loc)
|
|
41
|
+
VALUES (
|
|
42
|
+
ST_SetSRID(ST_MakePoint(-122.4194, 37.7749), 3857)
|
|
43
|
+
);
|
|
44
|
+
`)).rejects.toThrow();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('fails if polygon is invalid', async () => {
|
|
48
|
+
await expect(pg.any(`
|
|
49
|
+
INSERT INTO places (area)
|
|
50
|
+
VALUES (
|
|
51
|
+
ST_SetSRID(ST_GeomFromText('POLYGON((0 0, 1 1, 2 2))'), 4326)
|
|
52
|
+
);
|
|
53
|
+
`)).rejects.toThrow();
|
|
54
|
+
});
|
|
55
|
+
});
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
preset: 'ts-jest',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
|
|
6
|
+
// Match both __tests__ and colocated test files
|
|
7
|
+
testMatch: ['**/?(*.)+(test|spec).{ts,tsx,js,jsx}'],
|
|
8
|
+
|
|
9
|
+
// Ignore build artifacts and type declarations
|
|
10
|
+
testPathIgnorePatterns: ['/dist/', '\\.d\\.ts$'],
|
|
11
|
+
modulePathIgnorePatterns: ['<rootDir>/dist/'],
|
|
12
|
+
watchPathIgnorePatterns: ['/dist/'],
|
|
13
|
+
|
|
14
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
15
|
+
};
|
package/launchql.plan
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
%syntax-version=1.0.0
|
|
2
|
+
%project=launchql-geo-types
|
|
3
|
+
%uri=launchql-geo-types
|
|
4
|
+
|
|
5
|
+
schemas/public/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/schema
|
|
6
|
+
schemas/public/domains/geolocation [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/geolocation
|
|
7
|
+
schemas/public/domains/geopolygon [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/geopolygon
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pgpm/geotypes",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Geographic data types and spatial functions for PostgreSQL",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"bundle": "lql package",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"test:watch": "jest --watch"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@pgpm/types": "0.4.0",
|
|
15
|
+
"@pgpm/verify": "0.4.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@launchql/cli": "^4.9.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/launchql/extensions"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/launchql/extensions",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/launchql/extensions/issues"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "cc9f52a335caa6e21ee7751b04b77c84ce6cb809"
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- Revert schemas/public/schema from pg
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
\echo Use "CREATE EXTENSION launchql-geo-types" to load this file. \quit
|
|
2
|
+
CREATE DOMAIN geolocation AS geometry(point, 4326);
|
|
3
|
+
|
|
4
|
+
COMMENT ON DOMAIN geolocation IS '@name launchqlInternalTypeGeoLocation';
|
|
5
|
+
|
|
6
|
+
CREATE DOMAIN geopolygon AS geometry(polygon, 4326);
|
|
7
|
+
|
|
8
|
+
COMMENT ON DOMAIN geopolygon IS '@name launchqlInternalTypeGeoPolygon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- Verify schemas/public/schema on pg
|