@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 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
@@ -0,0 +1,6 @@
1
+ EXTENSION = launchql-geo-types
2
+ DATA = sql/launchql-geo-types--0.4.6.sql
3
+
4
+ PG_CONFIG = pg_config
5
+ PGXS := $(shell $(PG_CONFIG) --pgxs)
6
+ include $(PGXS)
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @pgpm/geotypes
2
+
3
+ Geographic data types and spatial functions for PostgreSQL.
4
+
5
+ Provides geographic data types and spatial utility functions for location-based applications and geographic information systems.
@@ -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
+ });
@@ -0,0 +1,10 @@
1
+ -- Deploy schemas/public/domains/geolocation to pg
2
+
3
+ -- requires: schemas/public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE DOMAIN geolocation AS geometry (Point, 4326);
8
+ COMMENT ON DOMAIN geolocation IS E'@name launchqlInternalTypeGeoLocation';
9
+
10
+ COMMIT;
@@ -0,0 +1,10 @@
1
+ -- Deploy schemas/public/domains/geopolygon to pg
2
+
3
+ -- requires: schemas/public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE DOMAIN geopolygon AS geometry (Polygon, 4326);
8
+ COMMENT ON DOMAIN geopolygon IS E'@name launchqlInternalTypeGeoPolygon';
9
+
10
+ COMMIT;
@@ -0,0 +1,2 @@
1
+ -- Deploy schemas/public/schema to pg
2
+
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
+ };
@@ -0,0 +1,8 @@
1
+ # launchql-geo-types extension
2
+ comment = 'launchql-geo-types extension'
3
+ default_version = '0.4.6'
4
+ module_pathname = '$libdir/launchql-geo-types'
5
+ requires = 'plpgsql,citext,postgis,launchql-types,launchql-verify'
6
+ relocatable = false
7
+ superuser = false
8
+
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,7 @@
1
+ -- Revert schemas/public/domains/geolocation from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.geolocation;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/geopolygon from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.geopolygon;
6
+
7
+ COMMIT;
@@ -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,7 @@
1
+ -- Verify schemas/public/domains/geolocation on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.geolocation');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/geopolygon on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.geopolygon');
6
+
7
+ ROLLBACK;
@@ -0,0 +1 @@
1
+ -- Verify schemas/public/schema on pg