Change SRID to srid for option naming consistency

This commit is contained in:
kikuchan
2021-04-07 22:22:16 +09:00
parent 03485a1c98
commit 3c830d5b59
+19 -19
View File
@@ -63,7 +63,7 @@ class WkbReader {
this.hasZ = false; this.hasZ = false;
this.hasM = false; this.hasM = false;
/** @type {number} */ /** @type {number} */
this.SRID = null; this.srid = null;
this.layout = GeometryLayout.XY; this.layout = GeometryLayout.XY;
} }
@@ -168,7 +168,7 @@ class WkbReader {
const typeId = (wkbType & 0x0fffffff) % 1000; // Assume 1000 is an upper limit for type ID const typeId = (wkbType & 0x0fffffff) % 1000; // Assume 1000 is an upper limit for type ID
const layout = ['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join(''); const layout = ['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join('');
const SRID = hasSRID ? this.readUint32(isLittleEndian) : null; const srid = hasSRID ? this.readUint32(isLittleEndian) : null;
if (expectedTypeId !== undefined && expectedTypeId !== typeId) { if (expectedTypeId !== undefined && expectedTypeId !== typeId) {
throw new Error('Unexpected WKB geometry type ' + typeId); throw new Error('Unexpected WKB geometry type ' + typeId);
@@ -182,7 +182,7 @@ class WkbReader {
if (this.layout !== layout) { if (this.layout !== layout) {
throw new Error('Inconsistent geometry layout'); throw new Error('Inconsistent geometry layout');
} }
if (SRID && this.SRID !== SRID) { if (srid && this.srid !== srid) {
throw new Error('Inconsistent coordinate system (SRID)'); throw new Error('Inconsistent coordinate system (SRID)');
} }
} else { } else {
@@ -190,7 +190,7 @@ class WkbReader {
this.hasZ = hasZ; this.hasZ = hasZ;
this.hasM = hasM; this.hasM = hasM;
this.layout = layout; this.layout = layout;
this.SRID = SRID; this.srid = srid;
this.initialized = true; this.initialized = true;
} }
@@ -448,9 +448,9 @@ class WkbWriter {
/** /**
* @param {number} wkbType WKB Type ID * @param {number} wkbType WKB Type ID
* @param {number} [SRID] SRID * @param {number} [srid] SRID
*/ */
writeWkbHeader(wkbType, SRID) { writeWkbHeader(wkbType, srid) {
wkbType %= 1000; // Assume 1000 is an upper limit for type ID wkbType %= 1000; // Assume 1000 is an upper limit for type ID
if (this.layout.indexOf('Z') >= 0) { if (this.layout.indexOf('Z') >= 0) {
wkbType += this.isEWKB ? 0x80000000 : 1000; wkbType += this.isEWKB ? 0x80000000 : 1000;
@@ -458,14 +458,14 @@ class WkbWriter {
if (this.layout.indexOf('M') >= 0) { if (this.layout.indexOf('M') >= 0) {
wkbType += this.isEWKB ? 0x40000000 : 2000; wkbType += this.isEWKB ? 0x40000000 : 2000;
} }
if (this.isEWKB && Number.isInteger(SRID)) { if (this.isEWKB && Number.isInteger(srid)) {
wkbType |= 0x20000000; wkbType |= 0x20000000;
} }
this.writeUint8(this.isLittleEndian ? 1 : 0); this.writeUint8(this.isLittleEndian ? 1 : 0);
this.writeUint32(wkbType); this.writeUint32(wkbType);
if (this.isEWKB && Number.isInteger(SRID)) { if (this.isEWKB && Number.isInteger(srid)) {
this.writeUint32(SRID); this.writeUint32(srid);
} }
} }
@@ -561,9 +561,9 @@ class WkbWriter {
/** /**
* @param {import("../geom/Geometry.js").default} geom geometry * @param {import("../geom/Geometry.js").default} geom geometry
* @param {number} [SRID] SRID * @param {number} [srid] SRID
*/ */
writeGeometry(geom, SRID) { writeGeometry(geom, srid) {
const wkblut = { const wkblut = {
[GeometryType.POINT]: WKBGeometryType.POINT, [GeometryType.POINT]: WKBGeometryType.POINT,
[GeometryType.LINE_STRING]: WKBGeometryType.LINE_STRING, [GeometryType.LINE_STRING]: WKBGeometryType.LINE_STRING,
@@ -585,7 +585,7 @@ class WkbWriter {
this.layout = this.findMinimumLayout(geom); this.layout = this.findMinimumLayout(geom);
} }
this.writeWkbHeader(typeId, SRID); this.writeWkbHeader(typeId, srid);
if (geom instanceof SimpleGeometry) { if (geom instanceof SimpleGeometry) {
const writerLUT = { const writerLUT = {
@@ -639,7 +639,7 @@ class WkbWriter {
* @property {import("../geom/GeometryLayout").default} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect) * @property {import("../geom/GeometryLayout").default} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect)
* @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z. * @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z.
* @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M. * @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M.
* @property {number|boolean} [SRID=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`. * @property {number|boolean} [srid=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`.
*/ */
/** /**
@@ -670,7 +670,7 @@ class WKB extends FeatureFormat {
this.nodataZ = options.nodataZ || 0; this.nodataZ = options.nodataZ || 0;
this.nodataM = options.nodataM || 0; this.nodataM = options.nodataM || 0;
this.SRID = options.SRID; this.srid = options.srid;
} }
/** /**
@@ -753,7 +753,7 @@ class WKB extends FeatureFormat {
const reader = new WkbReader(view); const reader = new WkbReader(view);
reader.readWkbHeader(); reader.readWkbHeader();
return (reader.SRID && getProjection('EPSG:' + reader.SRID)) || undefined; return (reader.srid && getProjection('EPSG:' + reader.srid)) || undefined;
} }
/** /**
@@ -806,21 +806,21 @@ class WKB extends FeatureFormat {
}); });
// extract SRID from `dataProjection` // extract SRID from `dataProjection`
let SRID = Number.isInteger(this.SRID) ? Number(this.SRID) : null; let srid = Number.isInteger(this.srid) ? Number(this.srid) : null;
if (this.SRID !== false && !Number.isInteger(this.SRID)) { if (this.srid !== false && !Number.isInteger(this.srid)) {
const dataProjection = const dataProjection =
options.dataProjection && getProjection(options.dataProjection); options.dataProjection && getProjection(options.dataProjection);
if (dataProjection) { if (dataProjection) {
const code = dataProjection.getCode(); const code = dataProjection.getCode();
if (code.indexOf('EPSG:') === 0) { if (code.indexOf('EPSG:') === 0) {
SRID = Number(code.substring(5)); srid = Number(code.substring(5));
} }
} }
} }
writer.writeGeometry( writer.writeGeometry(
transformGeometryWithOptions(geometry, true, options), transformGeometryWithOptions(geometry, true, options),
SRID srid
); );
const buffer = writer.getBuffer(); const buffer = writer.getBuffer();