Skip to content

Conversation

@dixonyant
Copy link
Contributor

@dixonyant dixonyant commented Dec 31, 2025

Description:

We need a way to query pbf as geojson or arcgis json objects to speed up load times for larger data sets, such as on-demand feature loading in MapLibre.

Adding support for f=pbf-as-geojson and f=pbf-as-arcgis to queryFeatures() and queryAllFeatures() for issue #1271.

This PR adds two format query params to queryFeatures and queryAllFeatures:

	const options: IQueryFeaturesOptions | IQueryAllFeaturesOptions = {
		...params,
		f: "pbf-as-geojson" | "pbf-as-arcgis"
	}

Additions:

  • Generated new PBFFeatureCollection decoder file generated from the latest Esri proto spec.
  • Added two parsers adapted from Rowan's work in arcgis-pbf-parser.
    • exported two functions pbfToGeoJson() and pbfToArcGIS()
  • Added new query method to parse pbf raw responses and return geojson or arcgis json.
  • Tests: added live tests, query and parsers tests, and test helpers for managing geometry precision variance.

Known/future Issues: (pbf-as-arcgis)

  • Doesn't support Multipoint
  • hasn't been tested with 3D or HasZ Point objects
  • Doesn't support length property on IFields in pbf-to arcgis (see below)
  • esriFieldTypeString (sqlTypeNVarchar) decoded fields do not return a length property based on the current available proto spec.
  • More could be done with to pbfToArcGIS to add other geometry types to it and better error management if we choose to do a full suite support for REST JS for pbf-to-arcgis and upgrade to a newly generated proto definition that supports all new fields (like sqlType and length). But the use case for pbf-as-arcgis that is more than read-only seems to not exist for now.

Testing distribution:

LIVE Tests: test parser and query features against live endpoints

  • test query responses
  • test errors
  • test decoded object shape & equality
  • test geometry types
  • test geometry precisions

Local Tests:

  • Query Tests
    • Test query responses through fetch-mock
    • Test error states and status codes
  • Parser Tests
    • Test decoded object shape & equality
    • Test geometry types
    • Test geometry precisions

Copy link
Contributor

@patrickarlt patrickarlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dixonyant overall this looks good I have a few small tweaks in the comments. I would really like to see 3 tests that are specific to making sure the geometry parsing is working properly for points, lines and polygons. There is some testing of this in the live tests but I think a dedicated test for these with a single feature would be good.

Copy link
Contributor

@gowin20 gowin20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only comment is about the valid f values for queryAllFeatures. Everything else looks really good!

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
arcgis-rest-basemap-sessions.src 100% 100% 0
arcgis-rest-basemap-sessions.src.utils 100% 100% 0
arcgis-rest-demographics.src 100% 100% 0
arcgis-rest-developer-credentials.src 100% 100% 0
arcgis-rest-developer-credentials.src.shared 100% 100% 0
arcgis-rest-elevation.src 100% 100% 0
arcgis-rest-feature-service.src 100% 100% 0
arcgis-rest-feature-service.src.pbf-parser 100% 100% 0
arcgis-rest-geocoding.src 100% 100% 0
arcgis-rest-places.src 100% 100% 0
arcgis-rest-portal.src.groups 100% 100% 0
arcgis-rest-portal.src.items 100% 100% 0
arcgis-rest-portal.src.orgs 100% 100% 0
arcgis-rest-portal.src.services 100% 100% 0
arcgis-rest-portal.src.sharing 100% 100% 0
arcgis-rest-portal.src.users 100% 100% 0
arcgis-rest-portal.src.util 100% 100% 0
arcgis-rest-request.src 100% 100% 0
arcgis-rest-request.src.types 100% 100% 0
arcgis-rest-request.src.utils 100% 100% 0
arcgis-rest-routing.src 100% 100% 0
Summary 100% (2412 / 2412) 100% (1292 / 1292) 0

Minimum allowed line rate is 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants