fix(parcel-sync): fix ArcGIS 1000 server cap pagination + scan improvements
- eterra-client: detect server maxRecordCount cap in fetchAllLayerByWhere When server returns exactly 1000 (or other round cap) but we asked for 2000, recognize this as a server limit, adjust pageSize, and CONTINUE paginating. Previously: 1000 < 2000 -> break (lost all data beyond page 1). - no-geom-sync: count layers first, pass total to fetchAllLayer Belt-and-suspenders: even if cap detection misses, known total prevents early termination. Also use pageSize 1000 to match typical server cap. Clădiri count uses countLayer instead of fetching all OBJECTIDs. - UI: add include-no-geom checkbox in background sync section Users can toggle it independently of scan status. Shows '(scanare in curs)' hint when scan is still running.
This commit is contained in:
@@ -339,6 +339,11 @@ export class EterraClient {
|
||||
let offset = 0;
|
||||
const all: EsriFeature[] = [];
|
||||
|
||||
// ArcGIS servers have a maxRecordCount (typically 1000).
|
||||
// If we request 2000 but get exactly 1000, we hit the server cap.
|
||||
// Track this so we continue paginating instead of stopping.
|
||||
let serverMaxRecordCount: number | null = null;
|
||||
|
||||
while (true) {
|
||||
const params = new URLSearchParams();
|
||||
params.set("f", "json");
|
||||
@@ -375,11 +380,28 @@ export class EterraClient {
|
||||
break;
|
||||
}
|
||||
|
||||
// Detect server maxRecordCount cap:
|
||||
// If we asked for more than we got AND the result is a round number
|
||||
// (1000, 2000), the server likely capped us. Adjust pageSize to match.
|
||||
if (
|
||||
serverMaxRecordCount === null &&
|
||||
features.length < pageSize &&
|
||||
features.length > 0 &&
|
||||
features.length % 500 === 0 // round cap: 500, 1000, 1500, 2000...
|
||||
) {
|
||||
serverMaxRecordCount = features.length;
|
||||
pageSize = serverMaxRecordCount;
|
||||
// Don't break — this is a full page at server's cap, continue
|
||||
}
|
||||
|
||||
all.push(...features);
|
||||
offset += features.length;
|
||||
if (onProgress) onProgress(all.length, total);
|
||||
if (total && all.length >= total) break;
|
||||
if (features.length < pageSize) {
|
||||
|
||||
// End of data: fewer features than the effective page size
|
||||
const effectivePageSize = serverMaxRecordCount ?? pageSize;
|
||||
if (features.length < effectivePageSize) {
|
||||
const nextSize = PAGE_SIZE_FALLBACKS.find((s) => s < pageSize);
|
||||
if (total && all.length < total && nextSize) {
|
||||
pageSize = nextSize;
|
||||
|
||||
Reference in New Issue
Block a user