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

ngageoint / geopackage-js / 3971101424

pending completion
3971101424

push

github

Christopher Caldwell
update linux tile

3572 of 8035 branches covered (44.46%)

Branch coverage included in aggregate %.

15055 of 20471 relevant lines covered (73.54%)

1437.27 hits per line

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

68.18
/lib/srs/spatialReferenceSystem.ts
1
import { Projection, ProjectionConstants, Projections } from '@ngageoint/projections-js';
1✔
2
import { GeoPackageConstants } from '../geoPackageConstants';
1✔
3
import { GeometryTransform } from '@ngageoint/simple-features-proj-js';
1✔
4

5
/**
6
 * 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.
7
 * @class SpatialReferenceSystem
8
 */
9
export class SpatialReferenceSystem {
1✔
10
  /**
11
   * Human readable name of this SRS
12
   * @type {string}
13
   */
14
  srs_name: string;
15
  /**
16
   * Unique identifier for each Spatial Reference System within a GeoPackage
17
   * @type {Number}
18
   */
19
  srs_id: number;
20
  /**
21
   * Case-insensitive name of the defining organization e.g. EPSG or epsg
22
   * @type {string}
23
   */
24
  organization: string;
25
  /**
26
   * Numeric ID of the Spatial Reference System assigned by the organization
27
   * @type {Number}
28
   */
29
  organization_coordsys_id: number;
30
  /**
31
   * Well-known Text [32] Representation of the Spatial Reference System
32
   * @type {string}
33
   */
34
  definition: string;
35
  /**
36
   * Human readable description of this SRS
37
   * @type {string}
38
   */
39
  description: string;
40
  /**
41
   * Well-known Text Representation of the Spatial Reference System
42
   * @type {string}
43
   */
44
  definition_12_063: string;
45

46
  /**
47
   * Default Constructor
48
   */
49
  public constructor(...args) {
3,602✔
50
    if (args.length === 1 && args[0] instanceof SpatialReferenceSystem) {
1,801!
51
      this.srs_name = args[0].srs_name;
×
52
      this.srs_id = args[0].srs_id;
×
53
      this.organization = args[0].organization;
×
54
      this.organization_coordsys_id = args[0].organization_coordsys_id;
×
55
      this.definition = args[0].definition;
×
56
      this.description = args[0].description;
×
57
      this.definition_12_063 = args[0].definition_12_063;
×
58
    }
59
  }
60

61
  /**
62
   * Get the id
63
   *
64
   * @return id
65
   */
66
  public getId(): number {
1✔
67
    return this.srs_id;
×
68
  }
69

70
  /**
71
   * Set the id
72
   *
73
   * @param id id
74
   */
75
  public setId(id: number): void {
1✔
76
    this.srs_id = id;
×
77
  }
78

79
  /**
80
   * Get the srs name
81
   *
82
   * @return srs name
83
   */
84
  public getSrsName(): string {
1✔
85
    return this.srs_name;
9✔
86
  }
87

88
  /**
89
   * Set the srs name
90
   *
91
   * @param srs_name srs name
92
   */
93
  // eslint-disable-next-line @typescript-eslint/camelcase
94
  public setSrsName(srs_name: string): void {
1✔
95
    // eslint-disable-next-line @typescript-eslint/camelcase
96
    this.srs_name = srs_name;
1,087✔
97
  }
98

99
  /**
100
   * Get the srs id
101
   *
102
   * @return srs id
103
   */
104
  public getSrsId(): number {
1✔
105
    return this.srs_id;
280✔
106
  }
107

108
  /**
109
   * Set the srs id
110
   *
111
   * @param srs_id srs id
112
   */
113
  // eslint-disable-next-line @typescript-eslint/camelcase
114
  public setSrsId(srs_id: number): void {
1✔
115
    // eslint-disable-next-line @typescript-eslint/camelcase
116
    this.srs_id = srs_id;
1,087✔
117
  }
118

119
  /**
120
   * Get the organization
121
   *
122
   * @return organization
123
   */
124
  public getOrganization(): string {
1✔
125
    return this.organization;
9✔
126
  }
127

128
  /**
129
   * Set the organization
130
   *
131
   * @param organization organization
132
   */
133
  public setOrganization(organization: string): void {
1✔
134
    this.organization = organization;
1,091✔
135
  }
136

137
  /**
138
   * Get the organization coordsys id
139
   *
140
   * @return organization coordsys id
141
   */
142
  public getOrganizationCoordsysId(): number {
1✔
143
    return this.organization_coordsys_id;
9✔
144
  }
145

146
  /**
147
   * Set the organization coordsys id
148
   *
149
   * @param organization_coordsys_id organization coordsys id
150
   */
151
  // eslint-disable-next-line @typescript-eslint/camelcase
152
  public setOrganizationCoordsysId(organization_coordsys_id: number): void {
1✔
153
    // eslint-disable-next-line @typescript-eslint/camelcase
154
    this.organization_coordsys_id = organization_coordsys_id;
1,091✔
155
  }
156

157
  /**
158
   * Get the definition
159
   *
160
   * @return definition
161
   */
162
  public getDefinition(): string {
1✔
163
    return this.definition;
9✔
164
  }
165

166
  /**
167
   * Set the definition
168
   *
169
   * @param definition definition
170
   */
171
  public setDefinition(definition: string): void {
1✔
172
    this.definition = definition;
1,088✔
173
  }
174

175
  /**
176
   * Get the description
177
   *
178
   * @return description
179
   */
180
  public getDescription(): string {
1✔
181
    return this.description;
9✔
182
  }
183

184
  /**
185
   * Set the description
186
   *
187
   * @param description description
188
   */
189
  public setDescription(description: string): void {
1✔
190
    this.description = description;
1,087✔
191
  }
192

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

203
  /**
204
   * Set the 12_063 WKT definition
205
   *
206
   * @param definition_12_063 12_063 WKT definition
207
   */
208
  // eslint-disable-next-line @typescript-eslint/camelcase
209
  public setDefinition_12_063(definition_12_063: string): void {
1✔
210
    // eslint-disable-next-line @typescript-eslint/camelcase
211
    this.definition_12_063 = definition_12_063;
1,088✔
212
  }
213

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

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

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

280
  /**
281
   * Return the proj4 projection specified by this SpatialReferenceSystem
282
   * @return {*}
283
   */
284
  get projection(): Projection {
1✔
285
    let projection = null;
295✔
286
    const organization = this.organization != null ? this.organization.toUpperCase() : undefined;
295✔
287
    const orgCoordSysId = this.organization_coordsys_id != null ? this.organization_coordsys_id : undefined;
295✔
288
    if (organization === 'NONE') return null;
295✔
289
    if (organization != null && orgCoordSysId != null) {
294✔
290
      try {
293✔
291
        projection = Projections.getProjection(organization, orgCoordSysId);
293✔
292
      } catch (e) {}
293
    }
294
    if (projection == null) {
294✔
295
      if (this.definition_12_063 && this.definition_12_063 !== '' && this.definition_12_063 !== 'undefined') {
2!
296
        projection = Projections.getProjection(organization, orgCoordSysId, this.definition_12_063);
×
297
      } else if (this.definition && this.definition !== '' && this.definition !== 'undefined') {
2✔
298
        projection = Projections.getProjection(organization, orgCoordSysId, this.definition);
1✔
299
      }
300
    }
301
    return projection;
294✔
302
  }
303
}
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