• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ngageoint / geopackage-js / 3847620801

pending completion
3847620801

push

github

Christopher Caldwell
another batch of test case updates and fixes

3185 of 7992 branches covered (39.85%)

Branch coverage included in aggregate %.

662 of 662 new or added lines in 46 files covered. (100.0%)

14090 of 20348 relevant lines covered (69.25%)

621.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.2
/lib/srs/spatialReferenceSystem.ts
1
/**
2
 * SpatialReferenceSystem module.
3
 * @module core/srs
4
 */
5
import { Projection, ProjectionConstants, Projections } from '@ngageoint/projections-js';
1✔
6
import { GeoPackageConstants } from '../geoPackageConstants';
1✔
7
import { GeometryTransform } from '@ngageoint/simple-features-proj-js';
1✔
8

9
/**
10
 * Spatial Reference System object. The coordinate reference system definitions it contains are referenced by the GeoPackage Contents and GeometryColumns objects to relate the vector and tile data in user tables to locations on the earth.
11
 * @class SpatialReferenceSystem
12
 */
13
export class SpatialReferenceSystem {
1✔
14
  /**
15
   * Human readable name of this SRS
16
   * @type {string}
17
   */
18
  srs_name: string;
19
  /**
20
   * Unique identifier for each Spatial Reference System within a GeoPackage
21
   * @type {Number}
22
   */
23
  srs_id: number;
24
  /**
25
   * Case-insensitive name of the defining organization e.g. EPSG or epsg
26
   * @type {string}
27
   */
28
  organization: string;
29
  /**
30
   * Numeric ID of the Spatial Reference System assigned by the organization
31
   * @type {Number}
32
   */
33
  organization_coordsys_id: number;
34
  /**
35
   * Well-known Text [32] Representation of the Spatial Reference System
36
   * @type {string}
37
   */
38
  definition: string;
39
  /**
40
   * Human readable description of this SRS
41
   * @type {string}
42
   */
43
  description: string;
44
  /**
45
   * Well-known Text Representation of the Spatial Reference System
46
   * @type {string}
47
   */
48
  definition_12_063: string;
49

50
  /**
51
   * Default Constructor
52
   */
53
  public constructor(...args) {
2,146✔
54
    if (args.length === 1 && args[0] instanceof SpatialReferenceSystem) {
1,073!
55
      this.srs_name = args[0].srs_name;
×
56
      this.srs_id = args[0].srs_id;
×
57
      this.organization = args[0].organization;
×
58
      this.organization_coordsys_id = args[0].organization_coordsys_id;
×
59
      this.definition = args[0].definition;
×
60
      this.description = args[0].description;
×
61
      this.definition_12_063 = args[0].definition_12_063;
×
62
    }
63
  }
64

65
  /**
66
   * Get the id
67
   *
68
   * @return id
69
   */
70
  public getId(): number {
1✔
71
    return this.srs_id;
×
72
  }
73

74
  /**
75
   * Set the id
76
   *
77
   * @param id id
78
   */
79
  public setId(id: number): void {
1✔
80
    this.srs_id = id;
×
81
  }
82

83
  /**
84
   * Get the srs name
85
   *
86
   * @return srs name
87
   */
88
  public getSrsName(): string {
1✔
89
    return this.srs_name;
9✔
90
  }
91

92
  /**
93
   * Set the srs name
94
   *
95
   * @param srs_name srs name
96
   */
97
  // eslint-disable-next-line @typescript-eslint/camelcase
98
  public setSrsName(srs_name: string): void {
1✔
99
    // eslint-disable-next-line @typescript-eslint/camelcase
100
    this.srs_name = srs_name;
423✔
101
  }
102

103
  /**
104
   * Get the srs id
105
   *
106
   * @return srs id
107
   */
108
  public getSrsId(): number {
1✔
109
    return this.srs_id;
154✔
110
  }
111

112
  /**
113
   * Set the srs id
114
   *
115
   * @param srs_id srs id
116
   */
117
  // eslint-disable-next-line @typescript-eslint/camelcase
118
  public setSrsId(srs_id: number): void {
1✔
119
    // eslint-disable-next-line @typescript-eslint/camelcase
120
    this.srs_id = srs_id;
423✔
121
  }
122

123
  /**
124
   * Get the organization
125
   *
126
   * @return organization
127
   */
128
  public getOrganization(): string {
1✔
129
    return this.organization;
9✔
130
  }
131

132
  /**
133
   * Set the organization
134
   *
135
   * @param organization organization
136
   */
137
  public setOrganization(organization: string): void {
1✔
138
    this.organization = organization;
423✔
139
  }
140

141
  /**
142
   * Get the organization coordsys id
143
   *
144
   * @return organization coordsys id
145
   */
146
  public getOrganizationCoordsysId(): number {
1✔
147
    return this.organization_coordsys_id;
9✔
148
  }
149

150
  /**
151
   * Set the organization coordsys id
152
   *
153
   * @param organization_coordsys_id organization coordsys id
154
   */
155
  // eslint-disable-next-line @typescript-eslint/camelcase
156
  public setOrganizationCoordsysId(organization_coordsys_id: number): void {
1✔
157
    // eslint-disable-next-line @typescript-eslint/camelcase
158
    this.organization_coordsys_id = organization_coordsys_id;
423✔
159
  }
160

161
  /**
162
   * Get the definition
163
   *
164
   * @return definition
165
   */
166
  public getDefinition(): string {
1✔
167
    return this.definition;
9✔
168
  }
169

170
  /**
171
   * Set the definition
172
   *
173
   * @param definition definition
174
   */
175
  public setDefinition(definition: string): void {
1✔
176
    this.definition = definition;
423✔
177
  }
178

179
  /**
180
   * Get the description
181
   *
182
   * @return description
183
   */
184
  public getDescription(): string {
1✔
185
    return this.description;
9✔
186
  }
187

188
  /**
189
   * Set the description
190
   *
191
   * @param description description
192
   */
193
  public setDescription(description: string): void {
1✔
194
    this.description = description;
423✔
195
  }
196

197
  /**
198
   * Get the 12_063 WKT definition
199
   *
200
   * @return 12_06 3WKT definition
201
   */
202
  // eslint-disable-next-line @typescript-eslint/camelcase
203
  public getDefinition_12_063(): string {
1✔
204
    return this.definition_12_063;
×
205
  }
206

207
  /**
208
   * Set the 12_063 WKT definition
209
   *
210
   * @param definition_12_063 12_063 WKT definition
211
   */
212
  // eslint-disable-next-line @typescript-eslint/camelcase
213
  public setDefinition_12_063(definition_12_063: string): void {
1✔
214
    // eslint-disable-next-line @typescript-eslint/camelcase
215
    this.definition_12_063 = definition_12_063;
423✔
216
  }
217

218
  /**
219
   * Get the projection for the Spatial Reference System
220
   *
221
   * @return projection
222
   */
223
  public getProjection(): Projection {
1✔
224
    if (this.organization === 'NONE') return null;
176✔
225
    if (
168!
226
      this.organization != null &&
529✔
227
      this.organization.toUpperCase() === ProjectionConstants.AUTHORITY_EPSG &&
228
      (this.organization_coordsys_id === ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM ||
229
        this.organization_coordsys_id === ProjectionConstants.EPSG_WEB_MERCATOR)
230
    ) {
231
      return Projections.getProjection(ProjectionConstants.AUTHORITY_EPSG, this.organization_coordsys_id);
168✔
232
    } else if (
×
233
      this.definition_12_063 &&
×
234
      this.definition_12_063.trim().length !== 0 &&
235
      this.definition_12_063 !== GeoPackageConstants.UNDEFINED_DEFINITION
236
    ) {
237
      return Projections.getProjection(this.organization, this.organization_coordsys_id, this.definition_12_063);
×
238
    } else if (
×
239
      this.definition &&
×
240
      this.definition.trim().length !== 0 &&
241
      this.definition !== GeoPackageConstants.UNDEFINED_DEFINITION
242
    ) {
243
      return Projections.getProjection(this.organization, this.organization_coordsys_id, this.definition);
×
244
    }
245
    return null;
×
246
  }
247

248
  /**
249
   * Get the projection definition
250
   *
251
   * @return definition
252
   */
253
  public getProjectionDefinition(): string {
1✔
254
    let definition = this.getDefinition_12_063();
×
255
    if (
×
256
      definition == null ||
×
257
      definition.trim().length === 0 ||
258
      definition.trim() === GeoPackageConstants.UNDEFINED_DEFINITION
259
    ) {
260
      definition = this.getDefinition();
×
261
      if (
×
262
        definition == null ||
×
263
        definition.trim().length === 0 ||
264
        definition.trim() === GeoPackageConstants.UNDEFINED_DEFINITION
265
      ) {
266
        definition = null;
×
267
      }
268
    }
269
    return definition;
×
270
  }
271

272
  /**
273
   * Get the projection transform from the provided projection to the Spatial
274
   * Reference System projection
275
   *
276
   * @param projection
277
   *            from projection
278
   * @return projection transform
279
   */
280
  public getTransformation(projection: Projection): GeometryTransform {
1✔
281
    return GeometryTransform.create(projection, this.getProjection());
×
282
  }
283

284
  /**
285
   * Return the proj4 projection specified by this SpatialReferenceSystem
286
   * @return {*}
287
   */
288
  get projection(): Projection {
1✔
289
    if (this.organization === 'NONE') return null;
42✔
290
    if (
41✔
291
      !!this.organization &&
154✔
292
      this.organization.toUpperCase() === ProjectionConstants.AUTHORITY_EPSG &&
293
      (this.organization_coordsys_id === ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM ||
294
        this.organization_coordsys_id === ProjectionConstants.EPSG_WEB_MERCATOR)
295
    ) {
296
      return Projections.getProjection(ProjectionConstants.AUTHORITY_EPSG, this.organization_coordsys_id);
31✔
297
    } else if (this.definition_12_063 && this.definition_12_063 !== '' && this.definition_12_063 !== 'undefined') {
10✔
298
      Projections.setProjection(this.organization.toUpperCase(), this.organization_coordsys_id, this.definition_12_063);
8✔
299
      return Projections.getProjection(this.organization.toUpperCase(), this.organization_coordsys_id, this.definition_12_063);
7✔
300
    } else if (this.definition && this.definition !== '' && this.definition !== 'undefined') {
2✔
301
      Projections.setProjection(this.organization.toUpperCase(), this.organization_coordsys_id, this.definition);
1✔
302
      return Projections.getProjection(this.organization.toUpperCase(), this.organization_coordsys_id, this.definition);
×
303
    }
304
    return null;
1✔
305
  }
306
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc