catastrogps 1.2.2 → 2.1.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/README.md +52 -32
- package/dist/index.d.mts +486 -186
- package/dist/index.d.ts +486 -186
- package/dist/index.js +75 -28
- package/dist/index.mjs +74 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
AmbiguousReferenceError: () => AmbiguousReferenceError,
|
|
25
25
|
AuthenticationError: () => AuthenticationError,
|
|
26
26
|
COUNTRY_CODES: () => COUNTRY_CODES,
|
|
27
|
+
CROP_LANGUAGES: () => CROP_LANGUAGES,
|
|
27
28
|
CatastroGPS: () => CatastroGPS,
|
|
28
29
|
CatastroGPSError: () => CatastroGPSError,
|
|
29
30
|
CoverageError: () => CoverageError,
|
|
@@ -126,8 +127,8 @@ var NetworkError = class extends CatastroGPSError {
|
|
|
126
127
|
};
|
|
127
128
|
function errorFromResponse(status, body, retryAfter, quota) {
|
|
128
129
|
const code = typeof body.code === "string" ? body.code : void 0;
|
|
129
|
-
const message = typeof body.
|
|
130
|
-
const details = body.
|
|
130
|
+
const message = typeof body.message === "string" && body.message || typeof body.error === "string" && body.error || `HTTP ${status}`;
|
|
131
|
+
const details = body.details ?? body.data;
|
|
131
132
|
const options = { status, code, details, body };
|
|
132
133
|
if (code === "CNV_AMBIGUOUS" || status === 300) return new AmbiguousReferenceError(message, options);
|
|
133
134
|
if (code === "CNV_COVERAGE") return new CoverageError(message, options);
|
|
@@ -156,7 +157,7 @@ function errorFromResponse(status, body, retryAfter, quota) {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
// src/resources/export.ts
|
|
159
|
-
var FORMATS = ["kml", "gpx"
|
|
160
|
+
var FORMATS = ["kml", "gpx"];
|
|
160
161
|
var ExportResource = class {
|
|
161
162
|
constructor(client) {
|
|
162
163
|
this.client = client;
|
|
@@ -167,8 +168,8 @@ var ExportResource = class {
|
|
|
167
168
|
throw new CatastroGPSError(`format must be one of ${FORMATS.join(", ")}`);
|
|
168
169
|
}
|
|
169
170
|
if (!reference.trim()) throw new CatastroGPSError("reference must not be empty");
|
|
170
|
-
return this.client.request("GET", `/
|
|
171
|
-
query: {
|
|
171
|
+
return this.client.request("GET", `/v1/export/${format}`, {
|
|
172
|
+
query: { reference: reference.trim(), country: options.country },
|
|
172
173
|
raw: true
|
|
173
174
|
});
|
|
174
175
|
}
|
|
@@ -239,6 +240,7 @@ var ADDRESS_COUNTRY_CODES = [
|
|
|
239
240
|
"PT"
|
|
240
241
|
];
|
|
241
242
|
var UNITS_COUNTRY_CODES = ["ES", "PV", "NA"];
|
|
243
|
+
var CROP_LANGUAGES = ["es", "ca", "en", "pt", "fr", "it", "de", "pl", "nl", "cs"];
|
|
242
244
|
|
|
243
245
|
// src/resources/parcels.ts
|
|
244
246
|
var MIN_COMPARE = 2;
|
|
@@ -249,19 +251,29 @@ var ParcelsResource = class {
|
|
|
249
251
|
}
|
|
250
252
|
client;
|
|
251
253
|
async get(reference, options = {}) {
|
|
252
|
-
return this.client.request("GET", parcelPath(reference), {
|
|
254
|
+
return this.client.request("GET", parcelPath(reference), {
|
|
255
|
+
query: { country: options.country, lang: options.lang }
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
async subparcels(reference, options = {}) {
|
|
259
|
+
return this.client.request("GET", parcelPath(reference, "/subparcels"), {
|
|
260
|
+
query: { country: options.country, lang: options.lang }
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
async neighbors(reference, options = {}) {
|
|
264
|
+
return this.client.request("GET", parcelPath(reference, "/neighbors"), { query: { country: options.country } });
|
|
253
265
|
}
|
|
254
266
|
async atPoint(point) {
|
|
255
267
|
if (!Number.isFinite(point.lat) || !Number.isFinite(point.lng)) {
|
|
256
268
|
throw new CatastroGPSError("lat and lng must be finite numbers");
|
|
257
269
|
}
|
|
258
|
-
return this.client.request("GET", "/
|
|
270
|
+
return this.client.request("GET", "/v1/search/coordinates", {
|
|
259
271
|
query: { lat: point.lat, lng: point.lng, country: point.country }
|
|
260
272
|
});
|
|
261
273
|
}
|
|
262
274
|
async findByAddress(address) {
|
|
263
275
|
if (!address.trim()) throw new CatastroGPSError("address must not be empty");
|
|
264
|
-
return this.client.request("POST", "/
|
|
276
|
+
return this.client.request("POST", "/v1/search/address/parse", { body: { address: address.trim() } });
|
|
265
277
|
}
|
|
266
278
|
async geometry(reference, options = {}) {
|
|
267
279
|
return this.client.request("GET", parcelPath(reference, "/polygon"), { query: { country: options.country } });
|
|
@@ -270,10 +282,9 @@ var ParcelsResource = class {
|
|
|
270
282
|
return this.client.request("GET", parcelPath(reference, "/solar"), { query: { country: options.country } });
|
|
271
283
|
}
|
|
272
284
|
async agriculture(reference, options = {}) {
|
|
273
|
-
|
|
285
|
+
return this.client.request("GET", parcelPath(reference, "/agriculture"), {
|
|
274
286
|
query: { country: options.country }
|
|
275
287
|
});
|
|
276
|
-
return data.agro ?? data;
|
|
277
288
|
}
|
|
278
289
|
async terrain(reference, options = {}) {
|
|
279
290
|
return this.client.request("GET", parcelPath(reference, "/terrain"), { query: locatedQuery(options) });
|
|
@@ -296,14 +307,14 @@ var ParcelsResource = class {
|
|
|
296
307
|
if (parcels.length < MIN_COMPARE || parcels.length > MAX_COMPARE) {
|
|
297
308
|
throw new CatastroGPSError(`compare takes ${MIN_COMPARE} or ${MAX_COMPARE} parcels`);
|
|
298
309
|
}
|
|
299
|
-
const
|
|
310
|
+
const body = parcels.map((parcel) => {
|
|
300
311
|
if (!parcel.reference?.trim()) throw new CatastroGPSError("reference must not be empty");
|
|
301
312
|
if (!ENRICHMENT_COUNTRY_CODES.includes(parcel.country)) {
|
|
302
313
|
throw new CatastroGPSError(`country must be one of ${ENRICHMENT_COUNTRY_CODES.join(", ")}`);
|
|
303
314
|
}
|
|
304
|
-
return {
|
|
315
|
+
return { reference: parcel.reference.trim(), country: parcel.country };
|
|
305
316
|
});
|
|
306
|
-
return this.client.request("POST", "/
|
|
317
|
+
return this.client.request("POST", "/v1/parcels/compare", { body: { parcels: body } });
|
|
307
318
|
}
|
|
308
319
|
};
|
|
309
320
|
function locatedQuery(options) {
|
|
@@ -317,7 +328,7 @@ function locatedQuery(options) {
|
|
|
317
328
|
}
|
|
318
329
|
function parcelPath(reference, suffix = "") {
|
|
319
330
|
if (!reference.trim()) throw new CatastroGPSError("reference must not be empty");
|
|
320
|
-
return `/
|
|
331
|
+
return `/v1/parcels/${encodeURIComponent(reference.trim())}${suffix}`;
|
|
321
332
|
}
|
|
322
333
|
|
|
323
334
|
// src/resources/fincas.ts
|
|
@@ -330,7 +341,7 @@ var FincasResource = class {
|
|
|
330
341
|
async searchAddress(query) {
|
|
331
342
|
const params = typeof query === "string" ? { q: query } : query;
|
|
332
343
|
if (!params.q?.trim() && !params.street?.trim()) throw new CatastroGPSError("q or street is required");
|
|
333
|
-
return this.client.request("GET", "/
|
|
344
|
+
return this.client.request("GET", "/v1/search/address/candidates", {
|
|
334
345
|
query: {
|
|
335
346
|
country: params.country,
|
|
336
347
|
q: params.q?.trim(),
|
|
@@ -367,16 +378,16 @@ var FincasResource = class {
|
|
|
367
378
|
const first = pages[0].data;
|
|
368
379
|
const last = pages[pages.length - 1].data;
|
|
369
380
|
return {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
381
|
+
reference: first.reference,
|
|
382
|
+
address: first.address,
|
|
383
|
+
postalCode: first.postalCode,
|
|
384
|
+
municipality: first.municipality,
|
|
385
|
+
region: first.region,
|
|
386
|
+
mainUse: first.mainUse,
|
|
387
|
+
yearBuilt: first.yearBuilt,
|
|
388
|
+
propertyUnitCount: last.propertyUnitCount ?? pages.reduce((sum, p) => sum + p.data.units.length, 0),
|
|
389
|
+
units: pages.flatMap((page) => page.data.units),
|
|
390
|
+
constructions: pages.flatMap((page) => page.data.constructions ?? []),
|
|
380
391
|
dataSource: first.dataSource,
|
|
381
392
|
dataDate: first.dataDate,
|
|
382
393
|
attribution: first.attribution,
|
|
@@ -386,11 +397,41 @@ var FincasResource = class {
|
|
|
386
397
|
}
|
|
387
398
|
};
|
|
388
399
|
|
|
400
|
+
// src/resources/locations.ts
|
|
401
|
+
var LocationsResource = class {
|
|
402
|
+
constructor(client) {
|
|
403
|
+
this.client = client;
|
|
404
|
+
}
|
|
405
|
+
client;
|
|
406
|
+
async provinces() {
|
|
407
|
+
return this.client.request("GET", "/v1/locations/provinces");
|
|
408
|
+
}
|
|
409
|
+
async municipalities(region) {
|
|
410
|
+
return this.client.request("GET", "/v1/locations/municipalities", {
|
|
411
|
+
query: { region: required(region, "region") }
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
async streets(query) {
|
|
415
|
+
return this.client.request("GET", "/v1/locations/streets", {
|
|
416
|
+
query: {
|
|
417
|
+
region: required(query.region, "region"),
|
|
418
|
+
municipality: required(query.municipality, "municipality"),
|
|
419
|
+
name: query.name?.trim()
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
function required(value, name) {
|
|
425
|
+
const trimmed = value?.trim();
|
|
426
|
+
if (!trimmed) throw new CatastroGPSError(`${name} must not be empty`);
|
|
427
|
+
return trimmed;
|
|
428
|
+
}
|
|
429
|
+
|
|
389
430
|
// src/version.ts
|
|
390
|
-
var VERSION = "1.
|
|
431
|
+
var VERSION = "2.1.0";
|
|
391
432
|
|
|
392
433
|
// src/client.ts
|
|
393
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
434
|
+
var DEFAULT_BASE_URL = "https://api.parcelgps.com";
|
|
394
435
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
395
436
|
var DEFAULT_MAX_RETRIES = 2;
|
|
396
437
|
var BACKOFF_BASE_MS = 500;
|
|
@@ -401,6 +442,7 @@ var CatastroGPS = class {
|
|
|
401
442
|
parcels;
|
|
402
443
|
export;
|
|
403
444
|
fincas;
|
|
445
|
+
locations;
|
|
404
446
|
lastQuota;
|
|
405
447
|
apiKey;
|
|
406
448
|
baseUrl;
|
|
@@ -426,6 +468,7 @@ var CatastroGPS = class {
|
|
|
426
468
|
this.parcels = new ParcelsResource(this);
|
|
427
469
|
this.export = new ExportResource(this);
|
|
428
470
|
this.fincas = new FincasResource(this);
|
|
471
|
+
this.locations = new LocationsResource(this);
|
|
429
472
|
}
|
|
430
473
|
async searchAddressCandidates(query) {
|
|
431
474
|
return this.fincas.searchAddress(query);
|
|
@@ -437,7 +480,10 @@ var CatastroGPS = class {
|
|
|
437
480
|
return this.fincas.pages(refcat14, options);
|
|
438
481
|
}
|
|
439
482
|
async resolve(text, options = {}) {
|
|
440
|
-
return this.request("GET", "/
|
|
483
|
+
return this.request("GET", "/v1/resolve", { query: { q: text, hint: options.hint } });
|
|
484
|
+
}
|
|
485
|
+
async cropCatalog(options = {}) {
|
|
486
|
+
return this.request("GET", "/v1/reference/crops", { query: { lang: options.lang } });
|
|
441
487
|
}
|
|
442
488
|
async request(method, path, options = {}) {
|
|
443
489
|
const result = await this.conditionalRequest(method, path, options);
|
|
@@ -584,6 +630,7 @@ function sleep(ms) {
|
|
|
584
630
|
AmbiguousReferenceError,
|
|
585
631
|
AuthenticationError,
|
|
586
632
|
COUNTRY_CODES,
|
|
633
|
+
CROP_LANGUAGES,
|
|
587
634
|
CatastroGPS,
|
|
588
635
|
CatastroGPSError,
|
|
589
636
|
CoverageError,
|
package/dist/index.mjs
CHANGED
|
@@ -77,8 +77,8 @@ var NetworkError = class extends CatastroGPSError {
|
|
|
77
77
|
};
|
|
78
78
|
function errorFromResponse(status, body, retryAfter, quota) {
|
|
79
79
|
const code = typeof body.code === "string" ? body.code : void 0;
|
|
80
|
-
const message = typeof body.
|
|
81
|
-
const details = body.
|
|
80
|
+
const message = typeof body.message === "string" && body.message || typeof body.error === "string" && body.error || `HTTP ${status}`;
|
|
81
|
+
const details = body.details ?? body.data;
|
|
82
82
|
const options = { status, code, details, body };
|
|
83
83
|
if (code === "CNV_AMBIGUOUS" || status === 300) return new AmbiguousReferenceError(message, options);
|
|
84
84
|
if (code === "CNV_COVERAGE") return new CoverageError(message, options);
|
|
@@ -107,7 +107,7 @@ function errorFromResponse(status, body, retryAfter, quota) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// src/resources/export.ts
|
|
110
|
-
var FORMATS = ["kml", "gpx"
|
|
110
|
+
var FORMATS = ["kml", "gpx"];
|
|
111
111
|
var ExportResource = class {
|
|
112
112
|
constructor(client) {
|
|
113
113
|
this.client = client;
|
|
@@ -118,8 +118,8 @@ var ExportResource = class {
|
|
|
118
118
|
throw new CatastroGPSError(`format must be one of ${FORMATS.join(", ")}`);
|
|
119
119
|
}
|
|
120
120
|
if (!reference.trim()) throw new CatastroGPSError("reference must not be empty");
|
|
121
|
-
return this.client.request("GET", `/
|
|
122
|
-
query: {
|
|
121
|
+
return this.client.request("GET", `/v1/export/${format}`, {
|
|
122
|
+
query: { reference: reference.trim(), country: options.country },
|
|
123
123
|
raw: true
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -190,6 +190,7 @@ var ADDRESS_COUNTRY_CODES = [
|
|
|
190
190
|
"PT"
|
|
191
191
|
];
|
|
192
192
|
var UNITS_COUNTRY_CODES = ["ES", "PV", "NA"];
|
|
193
|
+
var CROP_LANGUAGES = ["es", "ca", "en", "pt", "fr", "it", "de", "pl", "nl", "cs"];
|
|
193
194
|
|
|
194
195
|
// src/resources/parcels.ts
|
|
195
196
|
var MIN_COMPARE = 2;
|
|
@@ -200,19 +201,29 @@ var ParcelsResource = class {
|
|
|
200
201
|
}
|
|
201
202
|
client;
|
|
202
203
|
async get(reference, options = {}) {
|
|
203
|
-
return this.client.request("GET", parcelPath(reference), {
|
|
204
|
+
return this.client.request("GET", parcelPath(reference), {
|
|
205
|
+
query: { country: options.country, lang: options.lang }
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async subparcels(reference, options = {}) {
|
|
209
|
+
return this.client.request("GET", parcelPath(reference, "/subparcels"), {
|
|
210
|
+
query: { country: options.country, lang: options.lang }
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async neighbors(reference, options = {}) {
|
|
214
|
+
return this.client.request("GET", parcelPath(reference, "/neighbors"), { query: { country: options.country } });
|
|
204
215
|
}
|
|
205
216
|
async atPoint(point) {
|
|
206
217
|
if (!Number.isFinite(point.lat) || !Number.isFinite(point.lng)) {
|
|
207
218
|
throw new CatastroGPSError("lat and lng must be finite numbers");
|
|
208
219
|
}
|
|
209
|
-
return this.client.request("GET", "/
|
|
220
|
+
return this.client.request("GET", "/v1/search/coordinates", {
|
|
210
221
|
query: { lat: point.lat, lng: point.lng, country: point.country }
|
|
211
222
|
});
|
|
212
223
|
}
|
|
213
224
|
async findByAddress(address) {
|
|
214
225
|
if (!address.trim()) throw new CatastroGPSError("address must not be empty");
|
|
215
|
-
return this.client.request("POST", "/
|
|
226
|
+
return this.client.request("POST", "/v1/search/address/parse", { body: { address: address.trim() } });
|
|
216
227
|
}
|
|
217
228
|
async geometry(reference, options = {}) {
|
|
218
229
|
return this.client.request("GET", parcelPath(reference, "/polygon"), { query: { country: options.country } });
|
|
@@ -221,10 +232,9 @@ var ParcelsResource = class {
|
|
|
221
232
|
return this.client.request("GET", parcelPath(reference, "/solar"), { query: { country: options.country } });
|
|
222
233
|
}
|
|
223
234
|
async agriculture(reference, options = {}) {
|
|
224
|
-
|
|
235
|
+
return this.client.request("GET", parcelPath(reference, "/agriculture"), {
|
|
225
236
|
query: { country: options.country }
|
|
226
237
|
});
|
|
227
|
-
return data.agro ?? data;
|
|
228
238
|
}
|
|
229
239
|
async terrain(reference, options = {}) {
|
|
230
240
|
return this.client.request("GET", parcelPath(reference, "/terrain"), { query: locatedQuery(options) });
|
|
@@ -247,14 +257,14 @@ var ParcelsResource = class {
|
|
|
247
257
|
if (parcels.length < MIN_COMPARE || parcels.length > MAX_COMPARE) {
|
|
248
258
|
throw new CatastroGPSError(`compare takes ${MIN_COMPARE} or ${MAX_COMPARE} parcels`);
|
|
249
259
|
}
|
|
250
|
-
const
|
|
260
|
+
const body = parcels.map((parcel) => {
|
|
251
261
|
if (!parcel.reference?.trim()) throw new CatastroGPSError("reference must not be empty");
|
|
252
262
|
if (!ENRICHMENT_COUNTRY_CODES.includes(parcel.country)) {
|
|
253
263
|
throw new CatastroGPSError(`country must be one of ${ENRICHMENT_COUNTRY_CODES.join(", ")}`);
|
|
254
264
|
}
|
|
255
|
-
return {
|
|
265
|
+
return { reference: parcel.reference.trim(), country: parcel.country };
|
|
256
266
|
});
|
|
257
|
-
return this.client.request("POST", "/
|
|
267
|
+
return this.client.request("POST", "/v1/parcels/compare", { body: { parcels: body } });
|
|
258
268
|
}
|
|
259
269
|
};
|
|
260
270
|
function locatedQuery(options) {
|
|
@@ -268,7 +278,7 @@ function locatedQuery(options) {
|
|
|
268
278
|
}
|
|
269
279
|
function parcelPath(reference, suffix = "") {
|
|
270
280
|
if (!reference.trim()) throw new CatastroGPSError("reference must not be empty");
|
|
271
|
-
return `/
|
|
281
|
+
return `/v1/parcels/${encodeURIComponent(reference.trim())}${suffix}`;
|
|
272
282
|
}
|
|
273
283
|
|
|
274
284
|
// src/resources/fincas.ts
|
|
@@ -281,7 +291,7 @@ var FincasResource = class {
|
|
|
281
291
|
async searchAddress(query) {
|
|
282
292
|
const params = typeof query === "string" ? { q: query } : query;
|
|
283
293
|
if (!params.q?.trim() && !params.street?.trim()) throw new CatastroGPSError("q or street is required");
|
|
284
|
-
return this.client.request("GET", "/
|
|
294
|
+
return this.client.request("GET", "/v1/search/address/candidates", {
|
|
285
295
|
query: {
|
|
286
296
|
country: params.country,
|
|
287
297
|
q: params.q?.trim(),
|
|
@@ -318,16 +328,16 @@ var FincasResource = class {
|
|
|
318
328
|
const first = pages[0].data;
|
|
319
329
|
const last = pages[pages.length - 1].data;
|
|
320
330
|
return {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
reference: first.reference,
|
|
332
|
+
address: first.address,
|
|
333
|
+
postalCode: first.postalCode,
|
|
334
|
+
municipality: first.municipality,
|
|
335
|
+
region: first.region,
|
|
336
|
+
mainUse: first.mainUse,
|
|
337
|
+
yearBuilt: first.yearBuilt,
|
|
338
|
+
propertyUnitCount: last.propertyUnitCount ?? pages.reduce((sum, p) => sum + p.data.units.length, 0),
|
|
339
|
+
units: pages.flatMap((page) => page.data.units),
|
|
340
|
+
constructions: pages.flatMap((page) => page.data.constructions ?? []),
|
|
331
341
|
dataSource: first.dataSource,
|
|
332
342
|
dataDate: first.dataDate,
|
|
333
343
|
attribution: first.attribution,
|
|
@@ -337,11 +347,41 @@ var FincasResource = class {
|
|
|
337
347
|
}
|
|
338
348
|
};
|
|
339
349
|
|
|
350
|
+
// src/resources/locations.ts
|
|
351
|
+
var LocationsResource = class {
|
|
352
|
+
constructor(client) {
|
|
353
|
+
this.client = client;
|
|
354
|
+
}
|
|
355
|
+
client;
|
|
356
|
+
async provinces() {
|
|
357
|
+
return this.client.request("GET", "/v1/locations/provinces");
|
|
358
|
+
}
|
|
359
|
+
async municipalities(region) {
|
|
360
|
+
return this.client.request("GET", "/v1/locations/municipalities", {
|
|
361
|
+
query: { region: required(region, "region") }
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
async streets(query) {
|
|
365
|
+
return this.client.request("GET", "/v1/locations/streets", {
|
|
366
|
+
query: {
|
|
367
|
+
region: required(query.region, "region"),
|
|
368
|
+
municipality: required(query.municipality, "municipality"),
|
|
369
|
+
name: query.name?.trim()
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
function required(value, name) {
|
|
375
|
+
const trimmed = value?.trim();
|
|
376
|
+
if (!trimmed) throw new CatastroGPSError(`${name} must not be empty`);
|
|
377
|
+
return trimmed;
|
|
378
|
+
}
|
|
379
|
+
|
|
340
380
|
// src/version.ts
|
|
341
|
-
var VERSION = "1.
|
|
381
|
+
var VERSION = "2.1.0";
|
|
342
382
|
|
|
343
383
|
// src/client.ts
|
|
344
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
384
|
+
var DEFAULT_BASE_URL = "https://api.parcelgps.com";
|
|
345
385
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
346
386
|
var DEFAULT_MAX_RETRIES = 2;
|
|
347
387
|
var BACKOFF_BASE_MS = 500;
|
|
@@ -352,6 +392,7 @@ var CatastroGPS = class {
|
|
|
352
392
|
parcels;
|
|
353
393
|
export;
|
|
354
394
|
fincas;
|
|
395
|
+
locations;
|
|
355
396
|
lastQuota;
|
|
356
397
|
apiKey;
|
|
357
398
|
baseUrl;
|
|
@@ -377,6 +418,7 @@ var CatastroGPS = class {
|
|
|
377
418
|
this.parcels = new ParcelsResource(this);
|
|
378
419
|
this.export = new ExportResource(this);
|
|
379
420
|
this.fincas = new FincasResource(this);
|
|
421
|
+
this.locations = new LocationsResource(this);
|
|
380
422
|
}
|
|
381
423
|
async searchAddressCandidates(query) {
|
|
382
424
|
return this.fincas.searchAddress(query);
|
|
@@ -388,7 +430,10 @@ var CatastroGPS = class {
|
|
|
388
430
|
return this.fincas.pages(refcat14, options);
|
|
389
431
|
}
|
|
390
432
|
async resolve(text, options = {}) {
|
|
391
|
-
return this.request("GET", "/
|
|
433
|
+
return this.request("GET", "/v1/resolve", { query: { q: text, hint: options.hint } });
|
|
434
|
+
}
|
|
435
|
+
async cropCatalog(options = {}) {
|
|
436
|
+
return this.request("GET", "/v1/reference/crops", { query: { lang: options.lang } });
|
|
392
437
|
}
|
|
393
438
|
async request(method, path, options = {}) {
|
|
394
439
|
const result = await this.conditionalRequest(method, path, options);
|
|
@@ -534,6 +579,7 @@ export {
|
|
|
534
579
|
AmbiguousReferenceError,
|
|
535
580
|
AuthenticationError,
|
|
536
581
|
COUNTRY_CODES,
|
|
582
|
+
CROP_LANGUAGES,
|
|
537
583
|
CatastroGPS,
|
|
538
584
|
CatastroGPSError,
|
|
539
585
|
CoverageError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catastrogps",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Official JavaScript/TypeScript client for the Catastro GPS API: parcels from 29 European countries (including the Basque Country and Navarre foral cadastres) by reference, coordinates or address; building units, terrain, ground motion, solar and more",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|