powersync 0.1.0 → 0.1.1
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/README.md +14 -14
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +9 -8
- package/dist/commands/instance/sync-rules/generate-schema.js +6 -6
- package/dist/constants.d.ts +2 -5
- package/dist/constants.js +4 -2
- package/dist/service/accounts.client.js +11129 -25
- package/dist/service/powersync.client.js +37453 -113
- package/dist/service/types.js +1 -1
- package/dist/service/utils.js +6 -6
- package/dist/utils.js +3 -3
- package/oclif.manifest.json +1 -1
- package/package.json +28 -20
- package/dist/powersync-sdk/accounts/api.d.ts +0 -717
- package/dist/powersync-sdk/accounts/api.js +0 -182
- package/dist/powersync-sdk/accounts/client.d.ts +0 -1096
- package/dist/powersync-sdk/accounts/client.js +0 -124
- package/dist/powersync-sdk/accounts/codecs.d.ts +0 -32
- package/dist/powersync-sdk/accounts/codecs.js +0 -93
- package/dist/powersync-sdk/accounts/index.d.ts +0 -4
- package/dist/powersync-sdk/accounts/index.js +0 -4
- package/dist/powersync-sdk/accounts/models.d.ts +0 -260
- package/dist/powersync-sdk/accounts/models.js +0 -96
- package/dist/powersync-sdk/accounts/routes.d.ts +0 -44
- package/dist/powersync-sdk/accounts/routes.js +0 -45
- package/dist/powersync-sdk/accounts/source.d.ts +0 -76
- package/dist/powersync-sdk/accounts/source.js +0 -32
- package/dist/powersync-sdk/errors/errors.d.ts +0 -62
- package/dist/powersync-sdk/errors/errors.js +0 -115
- package/dist/powersync-sdk/errors/index.d.ts +0 -2
- package/dist/powersync-sdk/errors/index.js +0 -2
- package/dist/powersync-sdk/errors/utils.d.ts +0 -4
- package/dist/powersync-sdk/errors/utils.js +0 -18
- package/dist/powersync-sdk/fetch-clients/codecs.d.ts +0 -4
- package/dist/powersync-sdk/fetch-clients/codecs.js +0 -34
- package/dist/powersync-sdk/fetch-clients/decoders.d.ts +0 -3
- package/dist/powersync-sdk/fetch-clients/decoders.js +0 -35
- package/dist/powersync-sdk/fetch-clients/definitions.d.ts +0 -97
- package/dist/powersync-sdk/fetch-clients/definitions.js +0 -22
- package/dist/powersync-sdk/fetch-clients/errors.d.ts +0 -7
- package/dist/powersync-sdk/fetch-clients/errors.js +0 -19
- package/dist/powersync-sdk/fetch-clients/index.d.ts +0 -5
- package/dist/powersync-sdk/fetch-clients/index.js +0 -5
- package/dist/powersync-sdk/fetch-clients/node-client.d.ts +0 -9
- package/dist/powersync-sdk/fetch-clients/node-client.js +0 -107
- package/dist/powersync-sdk/fetch-clients/request.d.ts +0 -11
- package/dist/powersync-sdk/fetch-clients/request.js +0 -138
- package/dist/powersync-sdk/fetch-clients/streaming.d.ts +0 -65
- package/dist/powersync-sdk/fetch-clients/streaming.js +0 -99
- package/dist/powersync-sdk/fetch-clients/utils.d.ts +0 -13
- package/dist/powersync-sdk/fetch-clients/utils.js +0 -43
- package/dist/powersync-sdk/fetch-clients/web-client.d.ts +0 -14
- package/dist/powersync-sdk/fetch-clients/web-client.js +0 -56
- package/dist/powersync-sdk/json/index.d.ts +0 -4
- package/dist/powersync-sdk/json/index.js +0 -3
- package/dist/powersync-sdk/json/json.d.ts +0 -5
- package/dist/powersync-sdk/json/json.js +0 -35
- package/dist/powersync-sdk/json/json_container.d.ts +0 -18
- package/dist/powersync-sdk/json/json_container.js +0 -28
- package/dist/powersync-sdk/json/json_stringify.d.ts +0 -36
- package/dist/powersync-sdk/json/json_stringify.js +0 -162
- package/dist/powersync-sdk/powersync/client.d.ts +0 -449
- package/dist/powersync-sdk/powersync/client.js +0 -53
- package/dist/powersync-sdk/powersync/config/HostedConfig.d.ts +0 -327
- package/dist/powersync-sdk/powersync/config/HostedConfig.js +0 -92
- package/dist/powersync-sdk/powersync/config/PowerSyncConfig.d.ts +0 -211
- package/dist/powersync-sdk/powersync/config/PowerSyncConfig.js +0 -97
- package/dist/powersync-sdk/powersync/config/normalize.d.ts +0 -32
- package/dist/powersync-sdk/powersync/config/normalize.js +0 -85
- package/dist/powersync-sdk/powersync/definitions.d.ts +0 -149
- package/dist/powersync-sdk/powersync/definitions.js +0 -97
- package/dist/powersync-sdk/powersync/index.d.ts +0 -8
- package/dist/powersync-sdk/powersync/index.js +0 -8
- package/dist/powersync-sdk/powersync/internal_routes.d.ts +0 -247
- package/dist/powersync-sdk/powersync/internal_routes.js +0 -69
- package/dist/powersync-sdk/powersync/routes.d.ts +0 -779
- package/dist/powersync-sdk/powersync/routes.js +0 -191
- package/dist/powersync-sdk/sdk-clients/endpoints.d.ts +0 -31
- package/dist/powersync-sdk/sdk-clients/endpoints.js +0 -48
- package/dist/powersync-sdk/sdk-clients/index.d.ts +0 -3
- package/dist/powersync-sdk/sdk-clients/index.js +0 -3
- package/dist/powersync-sdk/sdk-clients/pagination.d.ts +0 -14
- package/dist/powersync-sdk/sdk-clients/pagination.js +0 -21
- package/dist/powersync-sdk/sdk-clients/sdk-client.d.ts +0 -17
- package/dist/powersync-sdk/sdk-clients/sdk-client.js +0 -30
- package/dist/powersync-sdk/streaming/bson/buffer-array.d.ts +0 -31
- package/dist/powersync-sdk/streaming/bson/buffer-array.js +0 -79
- package/dist/powersync-sdk/streaming/bson/constants.d.ts +0 -2
- package/dist/powersync-sdk/streaming/bson/constants.js +0 -1
- package/dist/powersync-sdk/streaming/bson/decoder.d.ts +0 -10
- package/dist/powersync-sdk/streaming/bson/decoder.js +0 -62
- package/dist/powersync-sdk/streaming/bson/encoder.d.ts +0 -10
- package/dist/powersync-sdk/streaming/bson/encoder.js +0 -23
- package/dist/powersync-sdk/streaming/bson/header.d.ts +0 -11
- package/dist/powersync-sdk/streaming/bson/header.js +0 -52
- package/dist/powersync-sdk/streaming/bson/index.d.ts +0 -5
- package/dist/powersync-sdk/streaming/bson/index.js +0 -5
- package/dist/powersync-sdk/streaming/core/backpressure.d.ts +0 -15
- package/dist/powersync-sdk/streaming/core/backpressure.js +0 -34
- package/dist/powersync-sdk/streaming/core/cross-stream.d.ts +0 -6
- package/dist/powersync-sdk/streaming/core/cross-stream.js +0 -17
- package/dist/powersync-sdk/streaming/core/index.d.ts +0 -4
- package/dist/powersync-sdk/streaming/core/index.js +0 -4
- package/dist/powersync-sdk/streaming/core/node-utils.d.ts +0 -7
- package/dist/powersync-sdk/streaming/core/node-utils.js +0 -11
- package/dist/powersync-sdk/streaming/core/transformers.d.ts +0 -41
- package/dist/powersync-sdk/streaming/core/transformers.js +0 -70
- package/dist/powersync-sdk/streaming/core/utils.d.ts +0 -36
- package/dist/powersync-sdk/streaming/core/utils.js +0 -66
- package/dist/powersync-sdk/streaming/index.d.ts +0 -3
- package/dist/powersync-sdk/streaming/index.js +0 -3
- package/dist/powersync-sdk/streaming/web.d.ts +0 -4
- package/dist/powersync-sdk/streaming/web.js +0 -4
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.d.ts +0 -2
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.js +0 -36
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.d.ts +0 -2
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.js +0 -58
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.d.ts +0 -18
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.js +0 -348
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.d.ts +0 -11
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.js +0 -118
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.d.ts +0 -11
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.js +0 -131
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.d.ts +0 -11
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.js +0 -134
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.d.ts +0 -11
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.js +0 -122
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.d.ts +0 -11
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.js +0 -158
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.d.ts +0 -14
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.js +0 -165
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.d.ts +0 -11
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.js +0 -207
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.d.ts +0 -30
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.js +0 -29
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.d.ts +0 -2
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.js +0 -111
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.d.ts +0 -9
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.js +0 -9
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.d.ts +0 -5
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.js +0 -9
- package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.d.ts +0 -12
- package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.js +0 -35
- package/dist/powersync-sdk/sync-rules/ExpressionType.d.ts +0 -33
- package/dist/powersync-sdk/sync-rules/ExpressionType.js +0 -62
- package/dist/powersync-sdk/sync-rules/IdSequence.d.ts +0 -4
- package/dist/powersync-sdk/sync-rules/IdSequence.js +0 -7
- package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.d.ts +0 -12
- package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.js +0 -38
- package/dist/powersync-sdk/sync-rules/SchemaGenerator.d.ts +0 -14
- package/dist/powersync-sdk/sync-rules/SchemaGenerator.js +0 -24
- package/dist/powersync-sdk/sync-rules/SourceTableInterface.d.ts +0 -5
- package/dist/powersync-sdk/sync-rules/SourceTableInterface.js +0 -1
- package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.d.ts +0 -37
- package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.js +0 -116
- package/dist/powersync-sdk/sync-rules/SqlDataQuery.d.ts +0 -39
- package/dist/powersync-sdk/sync-rules/SqlDataQuery.js +0 -245
- package/dist/powersync-sdk/sync-rules/SqlParameterQuery.d.ts +0 -43
- package/dist/powersync-sdk/sync-rules/SqlParameterQuery.js +0 -254
- package/dist/powersync-sdk/sync-rules/SqlSyncRules.d.ts +0 -52
- package/dist/powersync-sdk/sync-rules/SqlSyncRules.js +0 -252
- package/dist/powersync-sdk/sync-rules/StaticSchema.d.ts +0 -26
- package/dist/powersync-sdk/sync-rules/StaticSchema.js +0 -71
- package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.d.ts +0 -24
- package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.js +0 -71
- package/dist/powersync-sdk/sync-rules/TablePattern.d.ts +0 -17
- package/dist/powersync-sdk/sync-rules/TablePattern.js +0 -56
- package/dist/powersync-sdk/sync-rules/TableQuerySchema.d.ts +0 -9
- package/dist/powersync-sdk/sync-rules/TableQuerySchema.js +0 -41
- package/dist/powersync-sdk/sync-rules/errors.d.ts +0 -22
- package/dist/powersync-sdk/sync-rules/errors.js +0 -60
- package/dist/powersync-sdk/sync-rules/generators.d.ts +0 -6
- package/dist/powersync-sdk/sync-rules/generators.js +0 -6
- package/dist/powersync-sdk/sync-rules/index.d.ts +0 -17
- package/dist/powersync-sdk/sync-rules/index.js +0 -17
- package/dist/powersync-sdk/sync-rules/json_schema.d.ts +0 -3
- package/dist/powersync-sdk/sync-rules/json_schema.js +0 -50
- package/dist/powersync-sdk/sync-rules/sql_filters.d.ts +0 -91
- package/dist/powersync-sdk/sync-rules/sql_filters.js +0 -491
- package/dist/powersync-sdk/sync-rules/sql_functions.d.ts +0 -53
- package/dist/powersync-sdk/sync-rules/sql_functions.js +0 -755
- package/dist/powersync-sdk/sync-rules/sql_support.d.ts +0 -22
- package/dist/powersync-sdk/sync-rules/sql_support.js +0 -208
- package/dist/powersync-sdk/sync-rules/types.d.ts +0 -174
- package/dist/powersync-sdk/sync-rules/types.js +0 -9
- package/dist/powersync-sdk/sync-rules/utils.d.ts +0 -45
- package/dist/powersync-sdk/sync-rules/utils.js +0 -163
- package/dist/service/accounts.client.d.ts +0 -26
- package/dist/service/powersync.client.d.ts +0 -269
- package/dist/service/types.d.ts +0 -69
- package/dist/service/utils.d.ts +0 -5
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
/* eslint-disable radix */
|
|
2
|
-
/* eslint-disable no-bitwise */
|
|
3
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
export default Geometry;
|
|
6
|
-
import BinaryReader from './binaryreader.js';
|
|
7
|
-
import BinaryWriter from './binarywriter.js';
|
|
8
|
-
import GeometryCollection from './geometrycollection.js';
|
|
9
|
-
import LineString from './linestring.js';
|
|
10
|
-
import MultiLineString from './multilinestring.js';
|
|
11
|
-
import MultiPoint from './multipoint.js';
|
|
12
|
-
import MultiPolygon from './multipolygon.js';
|
|
13
|
-
import Point from './point.js';
|
|
14
|
-
import Polygon from './polygon.js';
|
|
15
|
-
import Types from './types.js';
|
|
16
|
-
import WktParser from './wktparser.js';
|
|
17
|
-
import ZigZag from './zigzag.js';
|
|
18
|
-
function Geometry() {
|
|
19
|
-
this.srid = undefined;
|
|
20
|
-
this.hasZ = false;
|
|
21
|
-
this.hasM = false;
|
|
22
|
-
}
|
|
23
|
-
Geometry.parse = function (value, options) {
|
|
24
|
-
const valueType = typeof value;
|
|
25
|
-
if (valueType === 'string' || value instanceof WktParser)
|
|
26
|
-
return Geometry._parseWkt(value);
|
|
27
|
-
if (Buffer.isBuffer(value) || value instanceof BinaryReader)
|
|
28
|
-
return Geometry._parseWkb(value, options);
|
|
29
|
-
throw new Error('first argument must be a string or Buffer');
|
|
30
|
-
};
|
|
31
|
-
Geometry._parseWkt = function (value) {
|
|
32
|
-
let srid;
|
|
33
|
-
const wktParser = value instanceof WktParser ? value : new WktParser(value);
|
|
34
|
-
const match = wktParser.matchRegex([/^SRID=(\d+);/]);
|
|
35
|
-
if (match)
|
|
36
|
-
srid = Number.parseInt(match[1], 10);
|
|
37
|
-
const geometryType = wktParser.matchType();
|
|
38
|
-
const dimension = wktParser.matchDimension();
|
|
39
|
-
const options = {
|
|
40
|
-
hasM: dimension.hasM,
|
|
41
|
-
hasZ: dimension.hasZ,
|
|
42
|
-
srid
|
|
43
|
-
};
|
|
44
|
-
switch (geometryType) {
|
|
45
|
-
case Types.wkt.Point: {
|
|
46
|
-
return Point._parseWkt(wktParser, options);
|
|
47
|
-
}
|
|
48
|
-
case Types.wkt.LineString: {
|
|
49
|
-
return LineString._parseWkt(wktParser, options);
|
|
50
|
-
}
|
|
51
|
-
case Types.wkt.Polygon: {
|
|
52
|
-
return Polygon._parseWkt(wktParser, options);
|
|
53
|
-
}
|
|
54
|
-
case Types.wkt.MultiPoint: {
|
|
55
|
-
return MultiPoint._parseWkt(wktParser, options);
|
|
56
|
-
}
|
|
57
|
-
case Types.wkt.MultiLineString: {
|
|
58
|
-
return MultiLineString._parseWkt(wktParser, options);
|
|
59
|
-
}
|
|
60
|
-
case Types.wkt.MultiPolygon: {
|
|
61
|
-
return MultiPolygon._parseWkt(wktParser, options);
|
|
62
|
-
}
|
|
63
|
-
case Types.wkt.GeometryCollection: {
|
|
64
|
-
return GeometryCollection._parseWkt(wktParser, options);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
Geometry._parseWkb = function (value, parentOptions) {
|
|
69
|
-
let geometryType;
|
|
70
|
-
const options = {};
|
|
71
|
-
const binaryReader = value instanceof BinaryReader ? value : new BinaryReader(value);
|
|
72
|
-
binaryReader.isBigEndian = !binaryReader.readInt8();
|
|
73
|
-
const wkbType = binaryReader.readUInt32();
|
|
74
|
-
options.hasSrid = (wkbType & 536870912) === 536870912;
|
|
75
|
-
options.isEwkb = wkbType & 536870912 || wkbType & 1073741824 || wkbType & 2147483648;
|
|
76
|
-
if (options.hasSrid)
|
|
77
|
-
options.srid = binaryReader.readUInt32();
|
|
78
|
-
options.hasZ = false;
|
|
79
|
-
options.hasM = false;
|
|
80
|
-
if (!options.isEwkb && (!parentOptions || !parentOptions.isEwkb)) {
|
|
81
|
-
if (wkbType >= 1000 && wkbType < 2000) {
|
|
82
|
-
options.hasZ = true;
|
|
83
|
-
geometryType = wkbType - 1000;
|
|
84
|
-
}
|
|
85
|
-
else if (wkbType >= 2000 && wkbType < 3000) {
|
|
86
|
-
options.hasM = true;
|
|
87
|
-
geometryType = wkbType - 2000;
|
|
88
|
-
}
|
|
89
|
-
else if (wkbType >= 3000 && wkbType < 4000) {
|
|
90
|
-
options.hasZ = true;
|
|
91
|
-
options.hasM = true;
|
|
92
|
-
geometryType = wkbType - 3000;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
geometryType = wkbType;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
if (wkbType & 2147483648)
|
|
100
|
-
options.hasZ = true;
|
|
101
|
-
if (wkbType & 1073741824)
|
|
102
|
-
options.hasM = true;
|
|
103
|
-
geometryType = wkbType & 0xf;
|
|
104
|
-
}
|
|
105
|
-
switch (geometryType) {
|
|
106
|
-
case Types.wkb.Point: {
|
|
107
|
-
return Point._parseWkb(binaryReader, options);
|
|
108
|
-
}
|
|
109
|
-
case Types.wkb.LineString: {
|
|
110
|
-
return LineString._parseWkb(binaryReader, options);
|
|
111
|
-
}
|
|
112
|
-
case Types.wkb.Polygon: {
|
|
113
|
-
return Polygon._parseWkb(binaryReader, options);
|
|
114
|
-
}
|
|
115
|
-
case Types.wkb.MultiPoint: {
|
|
116
|
-
return MultiPoint._parseWkb(binaryReader, options);
|
|
117
|
-
}
|
|
118
|
-
case Types.wkb.MultiLineString: {
|
|
119
|
-
return MultiLineString._parseWkb(binaryReader, options);
|
|
120
|
-
}
|
|
121
|
-
case Types.wkb.MultiPolygon: {
|
|
122
|
-
return MultiPolygon._parseWkb(binaryReader, options);
|
|
123
|
-
}
|
|
124
|
-
case Types.wkb.GeometryCollection: {
|
|
125
|
-
return GeometryCollection._parseWkb(binaryReader, options);
|
|
126
|
-
}
|
|
127
|
-
default: {
|
|
128
|
-
throw new Error('GeometryType ' + geometryType + ' not supported');
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
Geometry.parseTwkb = function (value) {
|
|
133
|
-
const options = {};
|
|
134
|
-
const binaryReader = value instanceof BinaryReader ? value : new BinaryReader(value);
|
|
135
|
-
const type = binaryReader.readUInt8();
|
|
136
|
-
const metadataHeader = binaryReader.readUInt8();
|
|
137
|
-
const geometryType = type & 0x0f;
|
|
138
|
-
options.precision = ZigZag.decode(type >> 4);
|
|
139
|
-
options.precisionFactor = 10 ** options.precision;
|
|
140
|
-
options.hasBoundingBox = Math.trunc(metadataHeader) & 1;
|
|
141
|
-
options.hasSizeAttribute = (metadataHeader >> 1) & 1;
|
|
142
|
-
options.hasIdList = (metadataHeader >> 2) & 1;
|
|
143
|
-
options.hasExtendedPrecision = (metadataHeader >> 3) & 1;
|
|
144
|
-
options.isEmpty = (metadataHeader >> 4) & 1;
|
|
145
|
-
if (options.hasExtendedPrecision) {
|
|
146
|
-
const extendedPrecision = binaryReader.readUInt8();
|
|
147
|
-
options.hasZ = (extendedPrecision & 0x01) === 0x01;
|
|
148
|
-
options.hasM = (extendedPrecision & 0x02) === 0x02;
|
|
149
|
-
options.zPrecision = ZigZag.decode((extendedPrecision & 0x1c) >> 2);
|
|
150
|
-
options.zPrecisionFactor = 10 ** options.zPrecision;
|
|
151
|
-
options.mPrecision = ZigZag.decode((extendedPrecision & 0xe0) >> 5);
|
|
152
|
-
options.mPrecisionFactor = 10 ** options.mPrecision;
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
options.hasZ = false;
|
|
156
|
-
options.hasM = false;
|
|
157
|
-
}
|
|
158
|
-
if (options.hasSizeAttribute)
|
|
159
|
-
binaryReader.readVarInt();
|
|
160
|
-
if (options.hasBoundingBox) {
|
|
161
|
-
let dimensions = 2;
|
|
162
|
-
if (options.hasZ)
|
|
163
|
-
dimensions++;
|
|
164
|
-
if (options.hasM)
|
|
165
|
-
dimensions++;
|
|
166
|
-
for (let i = 0; i < dimensions; i++) {
|
|
167
|
-
binaryReader.readVarInt();
|
|
168
|
-
binaryReader.readVarInt();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
switch (geometryType) {
|
|
172
|
-
case Types.wkb.Point: {
|
|
173
|
-
return Point._parseTwkb(binaryReader, options);
|
|
174
|
-
}
|
|
175
|
-
case Types.wkb.LineString: {
|
|
176
|
-
return LineString._parseTwkb(binaryReader, options);
|
|
177
|
-
}
|
|
178
|
-
case Types.wkb.Polygon: {
|
|
179
|
-
return Polygon._parseTwkb(binaryReader, options);
|
|
180
|
-
}
|
|
181
|
-
case Types.wkb.MultiPoint: {
|
|
182
|
-
return MultiPoint._parseTwkb(binaryReader, options);
|
|
183
|
-
}
|
|
184
|
-
case Types.wkb.MultiLineString: {
|
|
185
|
-
return MultiLineString._parseTwkb(binaryReader, options);
|
|
186
|
-
}
|
|
187
|
-
case Types.wkb.MultiPolygon: {
|
|
188
|
-
return MultiPolygon._parseTwkb(binaryReader, options);
|
|
189
|
-
}
|
|
190
|
-
case Types.wkb.GeometryCollection: {
|
|
191
|
-
return GeometryCollection._parseTwkb(binaryReader, options);
|
|
192
|
-
}
|
|
193
|
-
default: {
|
|
194
|
-
throw new Error('GeometryType ' + geometryType + ' not supported');
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
Geometry.parseGeoJSON = function (value) {
|
|
199
|
-
return Geometry._parseGeoJSON(value);
|
|
200
|
-
};
|
|
201
|
-
Geometry._parseGeoJSON = function (value, isSubGeometry) {
|
|
202
|
-
let geometry;
|
|
203
|
-
switch (value.type) {
|
|
204
|
-
case Types.geoJSON.Point: {
|
|
205
|
-
geometry = Point._parseGeoJSON(value);
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
case Types.geoJSON.LineString: {
|
|
209
|
-
geometry = LineString._parseGeoJSON(value);
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
case Types.geoJSON.Polygon: {
|
|
213
|
-
geometry = Polygon._parseGeoJSON(value);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
case Types.geoJSON.MultiPoint: {
|
|
217
|
-
geometry = MultiPoint._parseGeoJSON(value);
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
case Types.geoJSON.MultiLineString: {
|
|
221
|
-
geometry = MultiLineString._parseGeoJSON(value);
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
case Types.geoJSON.MultiPolygon: {
|
|
225
|
-
geometry = MultiPolygon._parseGeoJSON(value);
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
case Types.geoJSON.GeometryCollection: {
|
|
229
|
-
geometry = GeometryCollection._parseGeoJSON(value);
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
default: {
|
|
233
|
-
throw new Error('GeometryType ' + value.type + ' not supported');
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (value.crs && value.crs.type && value.crs.type === 'name' && value.crs.properties && value.crs.properties.name) {
|
|
237
|
-
const crs = value.crs.properties.name;
|
|
238
|
-
if (crs.indexOf('EPSG:') === 0)
|
|
239
|
-
geometry.srid = Number.parseInt(crs.slice(5));
|
|
240
|
-
else if (crs.indexOf('urn:ogc:def:crs:EPSG::') === 0)
|
|
241
|
-
geometry.srid = Number.parseInt(crs.slice(22));
|
|
242
|
-
else
|
|
243
|
-
throw new Error('Unsupported crs: ' + crs);
|
|
244
|
-
}
|
|
245
|
-
else if (!isSubGeometry) {
|
|
246
|
-
geometry.srid = 4326;
|
|
247
|
-
}
|
|
248
|
-
return geometry;
|
|
249
|
-
};
|
|
250
|
-
Geometry.prototype.toEwkt = function () {
|
|
251
|
-
return 'SRID=' + this.srid + ';' + this.toWkt();
|
|
252
|
-
};
|
|
253
|
-
Geometry.prototype.toEwkb = function () {
|
|
254
|
-
const ewkb = new BinaryWriter(this._getWkbSize() + 4);
|
|
255
|
-
const wkb = this.toWkb();
|
|
256
|
-
ewkb.writeInt8(1);
|
|
257
|
-
ewkb.writeUInt32LE((wkb.slice(1, 5).readUInt32LE(0) | 536870912) >>> 0, true);
|
|
258
|
-
ewkb.writeUInt32LE(this.srid);
|
|
259
|
-
ewkb.writeBuffer(wkb.slice(5));
|
|
260
|
-
return ewkb.buffer;
|
|
261
|
-
};
|
|
262
|
-
Geometry.prototype._getWktType = function (wktType, isEmpty) {
|
|
263
|
-
let wkt = wktType;
|
|
264
|
-
if (this.hasZ && this.hasM)
|
|
265
|
-
wkt += ' ZM ';
|
|
266
|
-
else if (this.hasZ)
|
|
267
|
-
wkt += ' Z ';
|
|
268
|
-
else if (this.hasM)
|
|
269
|
-
wkt += ' M ';
|
|
270
|
-
if (isEmpty && !this.hasZ && !this.hasM)
|
|
271
|
-
wkt += ' ';
|
|
272
|
-
if (isEmpty)
|
|
273
|
-
wkt += 'EMPTY';
|
|
274
|
-
return wkt;
|
|
275
|
-
};
|
|
276
|
-
Geometry.prototype._getWktCoordinate = function (point) {
|
|
277
|
-
let coordinates = point.x + ' ' + point.y;
|
|
278
|
-
if (this.hasZ)
|
|
279
|
-
coordinates += ' ' + point.z;
|
|
280
|
-
if (this.hasM)
|
|
281
|
-
coordinates += ' ' + point.m;
|
|
282
|
-
return coordinates;
|
|
283
|
-
};
|
|
284
|
-
Geometry.prototype._writeWkbType = function (wkb, geometryType, parentOptions) {
|
|
285
|
-
let dimensionType = 0;
|
|
286
|
-
if (this.srid === undefined && (!parentOptions || parentOptions.srid === undefined)) {
|
|
287
|
-
if (this.hasZ && this.hasM)
|
|
288
|
-
dimensionType += 3000;
|
|
289
|
-
else if (this.hasZ)
|
|
290
|
-
dimensionType += 1000;
|
|
291
|
-
else if (this.hasM)
|
|
292
|
-
dimensionType += 2000;
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
if (this.hasZ)
|
|
296
|
-
dimensionType |= 2147483648;
|
|
297
|
-
if (this.hasM)
|
|
298
|
-
dimensionType |= 1073741824;
|
|
299
|
-
}
|
|
300
|
-
wkb.writeUInt32LE((dimensionType + geometryType) >>> 0, true);
|
|
301
|
-
};
|
|
302
|
-
Geometry.getTwkbPrecision = function (xyPrecision, zPrecision, mPrecision) {
|
|
303
|
-
return {
|
|
304
|
-
m: mPrecision,
|
|
305
|
-
mFactor: 10 ** mPrecision,
|
|
306
|
-
xy: xyPrecision,
|
|
307
|
-
xyFactor: 10 ** xyPrecision,
|
|
308
|
-
z: zPrecision,
|
|
309
|
-
zFactor: 10 ** zPrecision
|
|
310
|
-
};
|
|
311
|
-
};
|
|
312
|
-
Geometry.prototype._writeTwkbHeader = function (twkb, geometryType, precision, isEmpty) {
|
|
313
|
-
const type = (ZigZag.encode(precision.xy) << 4) + geometryType;
|
|
314
|
-
let metadataHeader = (this.hasZ || this.hasM) << 3;
|
|
315
|
-
metadataHeader += isEmpty << 4;
|
|
316
|
-
twkb.writeUInt8(type);
|
|
317
|
-
twkb.writeUInt8(metadataHeader);
|
|
318
|
-
if (this.hasZ || this.hasM) {
|
|
319
|
-
let extendedPrecision = 0;
|
|
320
|
-
if (this.hasZ)
|
|
321
|
-
extendedPrecision |= 0x1;
|
|
322
|
-
if (this.hasM)
|
|
323
|
-
extendedPrecision |= 0x2;
|
|
324
|
-
twkb.writeUInt8(extendedPrecision);
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
Geometry.prototype.toGeoJSON = function (options) {
|
|
328
|
-
const geoJSON = {};
|
|
329
|
-
if (this.srid && options) {
|
|
330
|
-
if (options.shortCrs) {
|
|
331
|
-
geoJSON.crs = {
|
|
332
|
-
properties: {
|
|
333
|
-
name: 'EPSG:' + this.srid
|
|
334
|
-
},
|
|
335
|
-
type: 'name'
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
else if (options.longCrs) {
|
|
339
|
-
geoJSON.crs = {
|
|
340
|
-
properties: {
|
|
341
|
-
name: 'urn:ogc:def:crs:EPSG::' + this.srid
|
|
342
|
-
},
|
|
343
|
-
type: 'name'
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return geoJSON;
|
|
348
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare function GeometryCollection(geometries: any, srid: any): void;
|
|
2
|
-
declare namespace GeometryCollection {
|
|
3
|
-
var Z: (geometries: any, srid: any) => any;
|
|
4
|
-
var M: (geometries: any, srid: any) => any;
|
|
5
|
-
var ZM: (geometries: any, srid: any) => any;
|
|
6
|
-
var _parseWkt: (value: any, options: any) => any;
|
|
7
|
-
var _parseWkb: (value: any, options: any) => any;
|
|
8
|
-
var _parseTwkb: (value: any, options: any) => any;
|
|
9
|
-
var _parseGeoJSON: (value: any) => any;
|
|
10
|
-
}
|
|
11
|
-
export default GeometryCollection;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import BinaryWriter from './binarywriter.js';
|
|
2
|
-
import Geometry from './geometry.js';
|
|
3
|
-
import Types from './types.js';
|
|
4
|
-
function GeometryCollection(geometries, srid) {
|
|
5
|
-
Geometry.call(this);
|
|
6
|
-
this.geometries = geometries || [];
|
|
7
|
-
this.srid = srid;
|
|
8
|
-
if (this.geometries.length > 0) {
|
|
9
|
-
this.hasZ = this.geometries[0].hasZ;
|
|
10
|
-
this.hasM = this.geometries[0].hasM;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
// util.inherits(GeometryCollection, Geometry);
|
|
14
|
-
GeometryCollection.Z = function (geometries, srid) {
|
|
15
|
-
const geometryCollection = new GeometryCollection(geometries, srid);
|
|
16
|
-
geometryCollection.hasZ = true;
|
|
17
|
-
return geometryCollection;
|
|
18
|
-
};
|
|
19
|
-
GeometryCollection.M = function (geometries, srid) {
|
|
20
|
-
const geometryCollection = new GeometryCollection(geometries, srid);
|
|
21
|
-
geometryCollection.hasM = true;
|
|
22
|
-
return geometryCollection;
|
|
23
|
-
};
|
|
24
|
-
GeometryCollection.ZM = function (geometries, srid) {
|
|
25
|
-
const geometryCollection = new GeometryCollection(geometries, srid);
|
|
26
|
-
geometryCollection.hasZ = true;
|
|
27
|
-
geometryCollection.hasM = true;
|
|
28
|
-
return geometryCollection;
|
|
29
|
-
};
|
|
30
|
-
GeometryCollection._parseWkt = function (value, options) {
|
|
31
|
-
const geometryCollection = new GeometryCollection();
|
|
32
|
-
geometryCollection.srid = options.srid;
|
|
33
|
-
geometryCollection.hasZ = options.hasZ;
|
|
34
|
-
geometryCollection.hasM = options.hasM;
|
|
35
|
-
if (value.isMatch(['EMPTY']))
|
|
36
|
-
return geometryCollection;
|
|
37
|
-
value.expectGroupStart();
|
|
38
|
-
do {
|
|
39
|
-
geometryCollection.geometries.push(Geometry.parse(value));
|
|
40
|
-
} while (value.isMatch([',']));
|
|
41
|
-
value.expectGroupEnd();
|
|
42
|
-
return geometryCollection;
|
|
43
|
-
};
|
|
44
|
-
GeometryCollection._parseWkb = function (value, options) {
|
|
45
|
-
const geometryCollection = new GeometryCollection();
|
|
46
|
-
geometryCollection.srid = options.srid;
|
|
47
|
-
geometryCollection.hasZ = options.hasZ;
|
|
48
|
-
geometryCollection.hasM = options.hasM;
|
|
49
|
-
const geometryCount = value.readUInt32();
|
|
50
|
-
for (let i = 0; i < geometryCount; i++)
|
|
51
|
-
geometryCollection.geometries.push(Geometry.parse(value, options));
|
|
52
|
-
return geometryCollection;
|
|
53
|
-
};
|
|
54
|
-
GeometryCollection._parseTwkb = function (value, options) {
|
|
55
|
-
const geometryCollection = new GeometryCollection();
|
|
56
|
-
geometryCollection.hasZ = options.hasZ;
|
|
57
|
-
geometryCollection.hasM = options.hasM;
|
|
58
|
-
if (options.isEmpty)
|
|
59
|
-
return geometryCollection;
|
|
60
|
-
const geometryCount = value.readVarInt();
|
|
61
|
-
for (let i = 0; i < geometryCount; i++)
|
|
62
|
-
geometryCollection.geometries.push(Geometry.parseTwkb(value));
|
|
63
|
-
return geometryCollection;
|
|
64
|
-
};
|
|
65
|
-
GeometryCollection._parseGeoJSON = function (value) {
|
|
66
|
-
const geometryCollection = new GeometryCollection();
|
|
67
|
-
for (let i = 0; i < value.geometries.length; i++)
|
|
68
|
-
geometryCollection.geometries.push(Geometry._parseGeoJSON(value.geometries[i], true));
|
|
69
|
-
if (geometryCollection.geometries.length > 0)
|
|
70
|
-
geometryCollection.hasZ = geometryCollection.geometries[0].hasZ;
|
|
71
|
-
return geometryCollection;
|
|
72
|
-
};
|
|
73
|
-
GeometryCollection.prototype.toWkt = function () {
|
|
74
|
-
if (this.geometries.length === 0)
|
|
75
|
-
return this._getWktType(Types.wkt.GeometryCollection, true);
|
|
76
|
-
let wkt = this._getWktType(Types.wkt.GeometryCollection, false) + '(';
|
|
77
|
-
for (let i = 0; i < this.geometries.length; i++)
|
|
78
|
-
wkt += this.geometries[i].toWkt() + ',';
|
|
79
|
-
wkt = wkt.slice(0, -1);
|
|
80
|
-
wkt += ')';
|
|
81
|
-
return wkt;
|
|
82
|
-
};
|
|
83
|
-
GeometryCollection.prototype.toWkb = function () {
|
|
84
|
-
const wkb = new BinaryWriter(this._getWkbSize());
|
|
85
|
-
wkb.writeInt8(1);
|
|
86
|
-
this._writeWkbType(wkb, Types.wkb.GeometryCollection);
|
|
87
|
-
wkb.writeUInt32LE(this.geometries.length);
|
|
88
|
-
for (let i = 0; i < this.geometries.length; i++)
|
|
89
|
-
wkb.writeBuffer(this.geometries[i].toWkb({ srid: this.srid }));
|
|
90
|
-
return wkb.buffer;
|
|
91
|
-
};
|
|
92
|
-
GeometryCollection.prototype.toTwkb = function () {
|
|
93
|
-
const twkb = new BinaryWriter(0, true);
|
|
94
|
-
const precision = Geometry.getTwkbPrecision(5, 0, 0);
|
|
95
|
-
const isEmpty = this.geometries.length === 0;
|
|
96
|
-
this._writeTwkbHeader(twkb, Types.wkb.GeometryCollection, precision, isEmpty);
|
|
97
|
-
if (this.geometries.length > 0) {
|
|
98
|
-
twkb.writeVarInt(this.geometries.length);
|
|
99
|
-
for (let i = 0; i < this.geometries.length; i++)
|
|
100
|
-
twkb.writeBuffer(this.geometries[i].toTwkb());
|
|
101
|
-
}
|
|
102
|
-
return twkb.buffer;
|
|
103
|
-
};
|
|
104
|
-
GeometryCollection.prototype._getWkbSize = function () {
|
|
105
|
-
let size = 1 + 4 + 4;
|
|
106
|
-
for (let i = 0; i < this.geometries.length; i++)
|
|
107
|
-
size += this.geometries[i]._getWkbSize();
|
|
108
|
-
return size;
|
|
109
|
-
};
|
|
110
|
-
GeometryCollection.prototype.toGeoJSON = function (options) {
|
|
111
|
-
const geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
|
|
112
|
-
geoJSON.type = Types.geoJSON.GeometryCollection;
|
|
113
|
-
geoJSON.geometries = [];
|
|
114
|
-
for (let i = 0; i < this.geometries.length; i++)
|
|
115
|
-
geoJSON.geometries.push(this.geometries[i].toGeoJSON());
|
|
116
|
-
return geoJSON;
|
|
117
|
-
};
|
|
118
|
-
export default GeometryCollection;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default LineString;
|
|
2
|
-
declare function LineString(points: any, srid: any): void;
|
|
3
|
-
declare namespace LineString {
|
|
4
|
-
var Z: (points: any, srid: any) => any;
|
|
5
|
-
var M: (points: any, srid: any) => any;
|
|
6
|
-
var ZM: (points: any, srid: any) => any;
|
|
7
|
-
var _parseWkt: (value: any, options: any) => any;
|
|
8
|
-
var _parseWkb: (value: any, options: any) => any;
|
|
9
|
-
var _parseTwkb: (value: any, options: any) => any;
|
|
10
|
-
var _parseGeoJSON: (value: any) => any;
|
|
11
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prefer-spread */
|
|
2
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
export default LineString;
|
|
5
|
-
import BinaryWriter from './binarywriter.js';
|
|
6
|
-
import Geometry from './geometry.js';
|
|
7
|
-
import Point from './point.js';
|
|
8
|
-
import Types from './types.js';
|
|
9
|
-
function LineString(points, srid) {
|
|
10
|
-
Geometry.call(this);
|
|
11
|
-
this.points = points || [];
|
|
12
|
-
this.srid = srid;
|
|
13
|
-
if (this.points.length > 0) {
|
|
14
|
-
this.hasZ = this.points[0].hasZ;
|
|
15
|
-
this.hasM = this.points[0].hasM;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
// util.inherits(LineString, Geometry);
|
|
19
|
-
LineString.Z = function (points, srid) {
|
|
20
|
-
const lineString = new LineString(points, srid);
|
|
21
|
-
lineString.hasZ = true;
|
|
22
|
-
return lineString;
|
|
23
|
-
};
|
|
24
|
-
LineString.M = function (points, srid) {
|
|
25
|
-
const lineString = new LineString(points, srid);
|
|
26
|
-
lineString.hasM = true;
|
|
27
|
-
return lineString;
|
|
28
|
-
};
|
|
29
|
-
LineString.ZM = function (points, srid) {
|
|
30
|
-
const lineString = new LineString(points, srid);
|
|
31
|
-
lineString.hasZ = true;
|
|
32
|
-
lineString.hasM = true;
|
|
33
|
-
return lineString;
|
|
34
|
-
};
|
|
35
|
-
LineString._parseWkt = function (value, options) {
|
|
36
|
-
const lineString = new LineString();
|
|
37
|
-
lineString.srid = options.srid;
|
|
38
|
-
lineString.hasZ = options.hasZ;
|
|
39
|
-
lineString.hasM = options.hasM;
|
|
40
|
-
if (value.isMatch(['EMPTY']))
|
|
41
|
-
return lineString;
|
|
42
|
-
value.expectGroupStart();
|
|
43
|
-
lineString.points.push.apply(lineString.points, value.matchCoordinates(options));
|
|
44
|
-
value.expectGroupEnd();
|
|
45
|
-
return lineString;
|
|
46
|
-
};
|
|
47
|
-
LineString._parseWkb = function (value, options) {
|
|
48
|
-
const lineString = new LineString();
|
|
49
|
-
lineString.srid = options.srid;
|
|
50
|
-
lineString.hasZ = options.hasZ;
|
|
51
|
-
lineString.hasM = options.hasM;
|
|
52
|
-
const pointCount = value.readUInt32();
|
|
53
|
-
for (let i = 0; i < pointCount; i++)
|
|
54
|
-
lineString.points.push(Point._readWkbPoint(value, options));
|
|
55
|
-
return lineString;
|
|
56
|
-
};
|
|
57
|
-
LineString._parseTwkb = function (value, options) {
|
|
58
|
-
const lineString = new LineString();
|
|
59
|
-
lineString.hasZ = options.hasZ;
|
|
60
|
-
lineString.hasM = options.hasM;
|
|
61
|
-
if (options.isEmpty)
|
|
62
|
-
return lineString;
|
|
63
|
-
const previousPoint = new Point(0, 0, options.hasZ ? 0 : undefined, options.hasM ? 0 : undefined);
|
|
64
|
-
const pointCount = value.readVarInt();
|
|
65
|
-
for (let i = 0; i < pointCount; i++)
|
|
66
|
-
lineString.points.push(Point._readTwkbPoint(value, options, previousPoint));
|
|
67
|
-
return lineString;
|
|
68
|
-
};
|
|
69
|
-
LineString._parseGeoJSON = function (value) {
|
|
70
|
-
const lineString = new LineString();
|
|
71
|
-
if (value.coordinates.length > 0)
|
|
72
|
-
lineString.hasZ = value.coordinates[0].length > 2;
|
|
73
|
-
for (let i = 0; i < value.coordinates.length; i++)
|
|
74
|
-
lineString.points.push(Point._readGeoJSONPoint(value.coordinates[i]));
|
|
75
|
-
return lineString;
|
|
76
|
-
};
|
|
77
|
-
LineString.prototype.toWkt = function () {
|
|
78
|
-
if (this.points.length === 0)
|
|
79
|
-
return this._getWktType(Types.wkt.LineString, true);
|
|
80
|
-
return this._getWktType(Types.wkt.LineString, false) + this._toInnerWkt();
|
|
81
|
-
};
|
|
82
|
-
LineString.prototype._toInnerWkt = function () {
|
|
83
|
-
let innerWkt = '(';
|
|
84
|
-
for (let i = 0; i < this.points.length; i++)
|
|
85
|
-
innerWkt += this._getWktCoordinate(this.points[i]) + ',';
|
|
86
|
-
innerWkt = innerWkt.slice(0, -1);
|
|
87
|
-
innerWkt += ')';
|
|
88
|
-
return innerWkt;
|
|
89
|
-
};
|
|
90
|
-
LineString.prototype.toWkb = function (parentOptions) {
|
|
91
|
-
const wkb = new BinaryWriter(this._getWkbSize());
|
|
92
|
-
wkb.writeInt8(1);
|
|
93
|
-
this._writeWkbType(wkb, Types.wkb.LineString, parentOptions);
|
|
94
|
-
wkb.writeUInt32LE(this.points.length);
|
|
95
|
-
for (let i = 0; i < this.points.length; i++)
|
|
96
|
-
this.points[i]._writeWkbPoint(wkb);
|
|
97
|
-
return wkb.buffer;
|
|
98
|
-
};
|
|
99
|
-
LineString.prototype.toTwkb = function () {
|
|
100
|
-
const twkb = new BinaryWriter(0, true);
|
|
101
|
-
const precision = Geometry.getTwkbPrecision(5, 0, 0);
|
|
102
|
-
const isEmpty = this.points.length === 0;
|
|
103
|
-
this._writeTwkbHeader(twkb, Types.wkb.LineString, precision, isEmpty);
|
|
104
|
-
if (this.points.length > 0) {
|
|
105
|
-
twkb.writeVarInt(this.points.length);
|
|
106
|
-
const previousPoint = new Point(0, 0, 0, 0);
|
|
107
|
-
for (let i = 0; i < this.points.length; i++)
|
|
108
|
-
this.points[i]._writeTwkbPoint(twkb, precision, previousPoint);
|
|
109
|
-
}
|
|
110
|
-
return twkb.buffer;
|
|
111
|
-
};
|
|
112
|
-
LineString.prototype._getWkbSize = function () {
|
|
113
|
-
let coordinateSize = 16;
|
|
114
|
-
if (this.hasZ)
|
|
115
|
-
coordinateSize += 8;
|
|
116
|
-
if (this.hasM)
|
|
117
|
-
coordinateSize += 8;
|
|
118
|
-
return 1 + 4 + 4 + this.points.length * coordinateSize;
|
|
119
|
-
};
|
|
120
|
-
LineString.prototype.toGeoJSON = function (options) {
|
|
121
|
-
const geoJSON = Geometry.prototype.toGeoJSON.call(this, options);
|
|
122
|
-
geoJSON.type = Types.geoJSON.LineString;
|
|
123
|
-
geoJSON.coordinates = [];
|
|
124
|
-
for (let i = 0; i < this.points.length; i++) {
|
|
125
|
-
if (this.hasZ)
|
|
126
|
-
geoJSON.coordinates.push([this.points[i].x, this.points[i].y, this.points[i].z]);
|
|
127
|
-
else
|
|
128
|
-
geoJSON.coordinates.push([this.points[i].x, this.points[i].y]);
|
|
129
|
-
}
|
|
130
|
-
return geoJSON;
|
|
131
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare function MultiLineString(lineStrings: any, srid: any): void;
|
|
2
|
-
declare namespace MultiLineString {
|
|
3
|
-
var Z: (lineStrings: any, srid: any) => any;
|
|
4
|
-
var M: (lineStrings: any, srid: any) => any;
|
|
5
|
-
var ZM: (lineStrings: any, srid: any) => any;
|
|
6
|
-
var _parseWkt: (value: any, options: any) => any;
|
|
7
|
-
var _parseWkb: (value: any, options: any) => any;
|
|
8
|
-
var _parseTwkb: (value: any, options: any) => any;
|
|
9
|
-
var _parseGeoJSON: (value: any) => any;
|
|
10
|
-
}
|
|
11
|
-
export default MultiLineString;
|