Parsers¶
The regparse package. Contains parsers for ESRI feature services and WMSes.
An ESRI feature “parser” (really the requests library does most of the actual parsing).
Most of the utility functions are exposed but most applications won’t use them :func:make_node is generally the only point of interest here.
-
regparse.esri_feature.
get_legend_mapping
(data, layer_id)[source]¶ Generates a mapping of layer labels to image data URLs.
Parameters: - data (dict) – The initial payload to RCS (should contain a ‘service_url’ entry)
- layer_id – The id of the layer to create the mapping for.
Returns: dict – a mapping of ‘label’ => ‘data URI encoded image’
-
regparse.esri_feature.
get_legend_url
(feature_service_url)[source]¶ Converts a feature service URL into a legend request. Handles the optional ‘/’ at the end of requests.
Parameters: feature_service_url (str) – A URL pointing to an ESRI feature service Returns: str – A URL pointing to a legend request
-
regparse.esri_feature.
make_alias_mapping
(json_data)[source]¶ Generates a mapping of field names to field aliases.
Parameters: json_data (list) – An array of field objects, taken from the fields property of an ESRI feature service endpoint Returns: dict – a mapping of ‘name’ => ‘alias’
-
regparse.esri_feature.
make_data_grid
(json_data)[source]¶ Generate a RAMP datagrid by walking through the attributes. Iterates over all entries in fields that do not have a type of esriFieldTypeGeometry
Parameters: json_data (dict) – A dictionary containing scraped data from an ESRI feature service endpoint Returns: dict – A dictionary with a single entry gridColumns containing an array of datagrid objects
-
regparse.esri_feature.
make_extent
(json_data)[source]¶ Extracts the extent for the layer from ESRI’s JSON config.
Parameters: json_data (dict) – A dictionary containing scraped data from an ESRI feature service endpoint Returns: dict – A dictionary with the same data as the ESRI layerExtent node
-
regparse.esri_feature.
make_grid_col
(**kw)[source]¶ - Generate a RAMP compliant datagrid column object with the following defaults:
- fieldName ‘’ isSortable False sortType ‘string’ alignment 0
Parameters: kw – Takes keyword arguments and just fills in the defaults Returns: dict – a dictionary with the defaults applied
-
regparse.esri_feature.
make_node
(data, id, config)[source]¶ Generate a RAMP layer entry for an ESRI feature service.
Parameters: - data (dict) – The initial payload to RCS (should contain a ‘service_url’ entry)
- id (str) – An identifier for the layer (as this is unique it is generally supplied from :module:rcs )
Returns: dict – a RAMP configuration fragment representing the ESRI layer
-
regparse.esri_feature.
make_symbology
(json_data, data)[source]¶ Generates a symbology node for the RAMP configuration. Handles simple, unique value and class break renders; prefetches all symbology images.
Parameters: - json_data (dict) – A dictionary containing scraped data from an ESRI feature service endpoint
- data (dict) – The initial payload to RCS (should contain a ‘service_url’ entry)
Returns: dict – a symbology node
A WMS “parser” (barely does any parsing at the moment).
-
regparse.wms.
make_feature_info
(data)[source]¶ Make a RAMP feature info node, identifying the correct default parser to be used based on the MIME type of the feature info request.
- Currently accepted MIME types (in order of preference):
- ‘text/html’ ‘text/plain’ ‘application/json’
Parameters: data (dict) – The initial payload to RCS Returns: dict – A feature info configuration fragment; None if no valid mimeType was set
-
regparse.wms.
make_node
(data, id, config=None)[source]¶ Generate a RAMP layer entry for a WMS.
Parameters: - data (dict) – The initial payload to RCS
- id (str) – An identifier for the layer (as this is unique it is generally supplied from :module:rcs )
Returns: dict – a RAMP configuration fragment representing the WMS layer