IsraelHikingMap / Site

Israel Hiking Map has maps, route planning, and travel information for Israel. This repository holds the files needed for running the Israel Hiking Map site and apps.
https://israelhiking.osm.org.il/
Other
82 stars 33 forks source link

ESRI layers support under OpenLayers #860

Closed zstadler closed 5 years ago

zstadler commented 5 years ago

Feature

This issue aims at collecting the information for the potential support of ESRI layers under OpenLayers. In particular, ESRI server URLs that do not use the {x}, {y}, and {z} parameters.

ESRI Map Server

Use the export API to retrieve raster data with the following steps:

  1. Check the server capabilities: GET <baseurl>/?f=json where <baseurl> is the user-provided map address.

  2. Send an export request: GET <baseurl>/export?bbox=<bbox>&size=<width>,<height>&dpi=96&format=<format>&transparent=true&bboxSR=3857&imageSR=3857&f=json where

    • <bbox> is the bounding box of the map in EPSG 3857 coordinates
    • <width> and <height> are taken from the map size in pixels
    • <format> is one of the image formats listed in the supportedImageFormatTypes attribute of the step 1 response. Note that the native format is usually the first value in the comma-separated list. For example, PNG32 in the case of a PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP attribute value.
  3. download the image: GET the URL given by the href attribute the step 2

ESRI Feature Server

Feature server provide vector data. They usually are capable of providing GeoJSON output. However, the feature drawing description language is very rich and may require significant resources to implement the openlayers-equivalent of esri-leaflet-renderers

  1. Check the server capabilities: GET <baseurl>/?f=json where <baseurl> is the user-provided map address.

    • Supported query output formats are listed in the supportedQueryFormats attribute.
    • Drawing information for the features is described by the DrawingInfo attribute.
  2. Retrieve the features using the Query API: GET <baseurl>/query?returnGeometry=true&where=1=1&outSr=4326&outFields=*&inSr=4326&geometry={"xmin":<xmin>,"ymin":<ymin>,"xmax":<xmax>,"ymax":<ymax>,"spatialReference":{"wkid":4326}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&f=geojson where

    • <baseurl> is the user-provided map address.
    • <xmin>, <ymin>, <xmax>, and <ymax> are taken from the map bounding box in WGS84 (EPSG 4326) coordinates.
HarelM commented 5 years ago

@jgravois do you have any insight you can share on this? We're migrating from Leaflet to Openlayers and would like to avoid implementing stuff that were already implemented.

jgravois commented 5 years ago

@HarelM i don't know of any projects to simplify working with Esri services in OpenLayers.

HarelM commented 5 years ago

Also need to see if the following map server can be supported - seems like it does support tiles... https://geomolg.ps:6443/arcgis/rest/services/Orthophoto_WestBank_Aerial_2018_10cm_ITM_jpg_02/MapServer/

jgravois commented 5 years ago

you can find a couple examples of a Leaflet map that displays a custom CRS to load Esri services in projections other than web mercator here:

HarelM commented 5 years ago

Currently the only code I'm using for ESRI layers is to add tiles/{z}/{y}/{x} which is extremely naive. The above example from the site's facebook group doesn't work with this suffix. It did work however with leaflet-esri without any non-mercator projection stuff... I'm not sure how to proceed here as I don't even know where to start in order to support any of this in OpenLayers... :-(

zstadler commented 5 years ago

Alternatively, if we assume the site supports EPSG:3857 it would be possible to use the export API directly and get the image for the canvas or tile by providing the appropriate bounding box and size:

<base url>//export?bbox=<bbox>&size=<width>,<height>&dpi=96&transparent=true&bboxSR=3857&imageSR=3857&f=image

For example https://gis.shual.org.il/arcgis/rest/services/MAPS/Orto2015v1/MapServer/export?bbox=3871253.6211023764,3775332.316575884,3874311.1022337833,3773927.786181142&size=1280,588&dpi=96&transparent=true&bboxSR=3857&imageSR=3857&f=image

More information is available at ArcGIS REST API - EXPORT MAP

zstadler commented 5 years ago

Another direction for exploring is

https://openlayers.org/en/latest/apidoc/module-ol_source_ImageArcGISRest-ImageArcGISRest.html

zstadler commented 5 years ago

An example is available a

https://openlayers.org/en/latest/examples/arcgis-image.html

Its description says:

This example shows how to use a dynamic ArcGIS REST MapService. This source type supports Map and Image Services. For dyamic ArcGIS services.

zstadler commented 5 years ago

I've created an example where OpenLayers shows two ESRI MapServices: Orthophoto base map and a Geology overlay.

In the above example, the base map is an ImageLayer and the overlay is a TileLayer. TileLayers have better performance and would be preferred.

Feature Services are not supported. IMO, they are low priority.

HarelM commented 5 years ago

I don't see the overlay, am I missing something? Also how can I determine from URL that the user provides which type to use - image or tile?

jgravois commented 5 years ago

you should only use image if tiles either

  1. aren't present
  2. were cooked in a different CRS than the map you want to display.
HarelM commented 5 years ago

@jgravois Thanks for the info, but how I can know that given the user only sets a URL?

jgravois commented 5 years ago

by using the url to fetch additional metadata for the service.

http://gis.shual.org.il/arcgis/rest/services/MAPS/Orto2015v1/MapServer?f=json

related: https://github.com/Esri/esri-leaflet/issues/1104#issuecomment-401880031

HarelM commented 5 years ago

@jgravois thanks again!! To reduce complexity and maintenance what is planned for this feature is to use TileArcGISRest source without all the capabilities such as features server or different CRS. If we decide in the future that the extra capabilities have value for our users and that it's worth the effort we will open a separate issue.

zstadler commented 5 years ago

For the record, this also fixed the bug reported in #795