Skip to content

Commit 30319f3

Browse files
authored
Merge pull request #31 from Ecotrust/merge_2025_b
Merge 2025 b
2 parents 10127a2 + 5f0aa12 commit 30319f3

7 files changed

Lines changed: 717 additions & 451 deletions

File tree

API.md

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
# MP Visualize Module API Documentation
2+
3+
Disclaimer: This document was bootstapped using Github Copilot and GPT-4o. The content has been re-written for accuracy.
4+
5+
This documentation provides information on the API endpoints available in the MP Visualize module. These endpoints allow you to interact with bookmarks and user layers.
6+
7+
## Endpoints
8+
9+
### Bookmarks
10+
11+
#### Add Bookmark
12+
13+
**Method:** `RPC`: 'add_bookmark'
14+
15+
**Description:** Adds a new bookmark.
16+
17+
**Parameters:**
18+
- `name` (string): The name of the bookmark.
19+
- `description` (string): The description of the bookmark.
20+
- `url_hash` (string): The URL hash of the bookmark.
21+
- `json` (string): The JSON representation of the bookmark.
22+
23+
**Response:**
24+
- `200 OK`: A JSON object containing the details of the added bookmark.
25+
26+
#### Get Bookmarks
27+
28+
**Method:** `RPC`: 'get_bookmarks'
29+
30+
**Description:** Retrieves a list of all bookmarks for the current user.
31+
32+
**Response:**
33+
- `200 OK`: A JSON array containing the details of all bookmarks.
34+
```json
35+
{
36+
"jsonrpc": "2.0",
37+
"id": "",
38+
"result": [
39+
{
40+
"uid": "visualize_bookmark_123",
41+
"name": "Foo",
42+
"description": null,
43+
"hash": "x=-73.92&y=39.31&z=9&logo=true&controls=true&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B2%5D=&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B5%5D=&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B8%5D=&basemap=Ocean&tab=data&legends=false&layers=true",
44+
"sharing_groups": ["User Group 1"],
45+
"json": null
46+
},
47+
{
48+
"uid": "visualize_bookmark_1634",
49+
"name": "RYAN: User-Added ArcFeatureServer Layers",
50+
"description": "Aids to Navigation and Coastal Barrier Resource System",
51+
"hash": "x=-74.66&y=39.19&z=12.76&logo=true&controls=true&dls%5B%5D=true&dls%5B%5D=0.98&dls%5B%5D=visualize_userlayer_11&dls%5B%5D=true&dls%5B%5D=0.81&dls%5B%5D=visualize_userlayer_12&basemap=ocean&tab=designs&legends=false&layers
52+
=true",
53+
"sharing_groups": [],
54+
"json": "{\"x\":\"-74.66\",\"y\":\"39.19\",\"z\":12.76,\"basemap\":\"ocean\",\"layers\":[{\"visible\":true,\"opacity\":0.98,\"type\":\"ArcFeatureServer\",\"url\":\"https://coast.noaa.gov/arcgismc/rest/services/Hosted/AtoNs/Feature
55+
Server/\",\"name\":\"Hosted/AtoNs\",\"id\":\"visualize_userlayer_11\",\"order\":0,\"dynamic\":true,\"isUserLayer\":true,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"0\"},{\"visible\":true,\"opacity\":0.81,\"type\":\"ArcFeat
56+
ureServer\",\"url\":\"https://coast.noaa.gov/arcgismc/rest/services/Hosted/CoastalBarrierResourceSystem/FeatureServer/\",\"name\":\"Hosted/Coastal Barrier Resource System\",\"id\":\"visualize_userlayer_12\",\"order\":1,\"dynamic\"
57+
:true,\"isUserLayer\":true,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"0\"}],\"themes\":{\"ids\":[]},\"panel\":\"true\",\"legends\":\"false\",\"logo\":true}"
58+
},
59+
{
60+
"uid": "visualize_bookmark_1889",
61+
"name": "Monty Shapes",
62+
"description": "",
63+
"hash": "x=-74.79&y=38.16&z=10.20717889389412&logo=true&controls=true&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B%5D=76&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B%5D=78&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B%5D=77&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B%5D=75&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B%5D=74&dls%5B%5D=true&dls%5B%5D=0.5&dls%5B%5D=drawing_aoi_1477&basemap=ocean&tab=designs&legends=true&layers=true",
64+
"shared": true,
65+
"shared_by_user": 183,
66+
"shared_to_groups": [
67+
"Critters!"
68+
],
69+
"shared_by_name": "jay_odell",
70+
"json": "{\"x\":\"-74.79\",\"y\":\"38.16\",\"z\":10.20717889389412,\"basemap\":\"ocean\",\"layers\":[{\"visible\":true,\"opacity\":0.5,\"type\":\"ArcRest\",\"url\":\"https://maritimeboundaries.noaa.gov/arcgis/rest/services/MaritimeBoundaries/US_Maritime_Limits_Boundaries/MapServer/export\",\"name\":\"12NM Territorial Sea\",\"id\":76,\"order\":0,\"dynamic\":false,\"isUserLayer\":false,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"1\"},{\"visible\":true,\"opacity\":0.5,\"type\":\"ArcRest\",\"url\":\"https://maritimeboundaries.noaa.gov/arcgis/rest/services/MaritimeBoundaries/US_Maritime_Limits_Boundaries/MapServer/export\",\"name\":\"200NM EEZ and Maritime Boundaries\",\"id\":78,\"order\":1,\"dynamic\":false,\"isUserLayer\":false,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"3\"},{\"visible\":true,\"opacity\":0.5,\"type\":\"ArcRest\",\"url\":\"https://maritimeboundaries.noaa.gov/arcgis/rest/services/MaritimeBoundaries/US_Maritime_Limits_Boundaries/MapServer/export\",\"name\":\"24NM Contiguous Zone\",\"id\":77,\"order\":2,\"dynamic\":false,\"isUserLayer\":false,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"2\"},{\"visible\":true,\"opacity\":0.5,\"type\":\"ArcRest\",\"url\":\"/visualize/proxy?layer_id=75&url=https%3A%2F%2Fgis.boem.gov%2Farcgis%2Frest%2Fservices%2FBOEM_BSEE%2FMMC_Layers%2FMapServer%2Fexport%3F&proxy_params=true&proxy_tech=MapServer\",\"name\":\"Limit of OCSLA '8(g)' zone\",\"id\":75,\"order\":3,\"dynamic\":false,\"isUserLayer\":false,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"7\"},{\"visible\":true,\"opacity\":0.5,\"type\":\"ArcRest\",\"url\":\"/visualize/proxy?layer_id=74&url=https%3A%2F%2Fgis.boem.gov%2Farcgis%2Frest%2Fservices%2FBOEM_BSEE%2FMMC_Layers%2FMapServer%2Fexport%3F&proxy_params=true&proxy_tech=MapServer\",\"name\":\"Submerged Lands Act Boundary\",\"id\":74,\"order\":4,\"dynamic\":false,\"isUserLayer\":false,\"isMDAT\":false,\"isVTR\":false,\"arcgislayers\":\"8\"},{\"visible\":true,\"opacity\":0.5,\"type\":\"Vector\",\"name\":\"Monty shapes\",\"id\":\"drawing_aoi_1477\",\"order\":5,\"dynamic\":false,\"isUserLayer\":false,\"arcgislayers\":null}],\"themes\":{\"ids\":[]},\"panel\":\"true\",\"legends\":\"true\",\"logo\":true}"
71+
}
72+
]
73+
}
74+
```
75+
76+
**A note regarding this response**:
77+
Close inspection will reveal that there are some inconsistencies in the fields that come back. `uid`, `name`, `description`, `hash`, and `json` appear in each `result` item. Those that are owned by the user include the extra field `sharing_groups` to list the names of groups the user has shared this bookmark with (if any). Results shared with groups that the user belongs to, but do not belong to the user instead have the fields `shared`, `shared_by_user`, `shared_to_groups`, and `shared_by_name`.
78+
79+
**results fields breakdown**:
80+
| Field | Type | Example | user owns | Notes |
81+
|:------|:------|:-----|:------:|:----|
82+
|uid|str|"visualize_bookmark_123"| all |
83+
|name|str|"Bookmark 123"| all |
84+
|description|str|"a new bookmark!"| all | May be null or ""|
85+
|**hash**|str|"x=-124.3&y=41.2&z..."| all | The only 100% reliable description of desired behavior|
86+
|sharing_groups|list|["User Group 1"]| true |
87+
|json|str|"{\\"x\\":\\"-124.3\\",\\"y\\":\\"41.2\\",\\"z\\"" | all | Parsed version of hash. Unfortunately old records are `null`|
88+
|shared|bool|true|false| Indicates if this record is being shared from another user |
89+
|shared_by_user|int|123|false|The ID of the user who owns this bookmark|
90+
|shared_to_groups|list|["User Group 2"]|
91+
|shared_by_name|str|"The Rock"|false|User-readable name to help identify bookmark owner|
92+
|
93+
94+
**Parsing the `hash` or json**:
95+
The `hash` value is the ONLY sure way you can extract the map state from the bookmark. It is the query-string description of the map state you can find in your browser when using the desktop map. Since the addition of bookmarks, a new `json` field has been added to prevent the need to parse the hash, but as of yet, no data migration has been made to populate this 'json' value for all records. This section will outline how to interpret both.
96+
97+
__Map Focus__
98+
|Field|Type|Notes|
99+
|:----|:----|:----|
100+
|x|float| The longitude in WGS84 |
101+
|y|float| The latitude in WGS84 |
102+
|z|float| The zoom level: see [Esri](https://developers.arcgis.com/documentation/mapping-and-location-services/reference/zoom-levels-and-scale/), [OSM](https://wiki.openstreetmap.org/wiki/Zoom_levels)|
103+
|basemap|str| Descriptive name for the base layer: "ocean" (default), "[streets](https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/0/0/0)", "[topo](https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/0/0/0)", "[satellite](https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/0/0/0)", "[nautical](https://gis.charttools.noaa.gov/arcgis/rest/services/MCS/NOAAChartDisplay/MapServer/exts/MaritimeChartService/MapServer)", "[gray](https://a.basemaps.cartocdn.com/light_all/0/0/0.png)", "[nationalmap](https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/0/0/0)", "[osm](https://tile.openstreetmap.org/0/0/0.png)"|
104+
|
105+
106+
__UI State__
107+
108+
This is less useful for an external API
109+
|Field|Type|Notes|
110+
|:----|:----|:----|
111+
|themes|obj| Contains a single key 'ids' whose value is a list of Theme IDs to open by default. This is not fully operational for the mp Layers module|
112+
|logo|boolean| Show the portal logo (false for embeddable view)|
113+
|controls*|boolean| Show the controls (false for collapsed left-nav). Called 'panel' in `json`|
114+
|panel*|boolean| Show the controls (false for collapsed left-nav). Called 'controls' in `hash`|
115+
|tab|str|Specifies which left nav tab to open: "data", "active", "legend", "designs" ( for "MyPlanner") |
116+
|legends|bool| Unclear |
117+
|layers|bool| Unclear. When false seems to collapse the left nav panel|
118+
|
119+
120+
__Layers__
121+
122+
Here is where `hash` and `json` differ most. Both methods represent an array of values representing the layers from bottom to top (the first layer represented will be shown beneath all others). However, `hash` is composed of triplets of compressed data meant to fit in your browser address bar, where `json` can include all information needed to load the layer in a map without needing additional context.
123+
124+
- `hash`
125+
- This looks like `&dls%5B%5D=true&dls%5B%5D=0.8&dls%5B%5D=3940` which gets decoded as `&dls[]=true&dls[]=0.8&dls[]=3940`. Read this as:
126+
- Visibility (true/false) -- layers can be activated but not shown in the portal
127+
- Opacity (float 0.0 to 1.0) --whether or not the layer comes in with any opacity
128+
- id (int) the ID of the layer
129+
- `json`
130+
- Coming soon...
131+
132+
# Below this point has not been reviewed for accuracy
133+
134+
#### Load Bookmark
135+
136+
**Method:** `RPC`
137+
138+
**Description:** Retrieves a bookmark by ID.
139+
140+
**Parameters:**
141+
- `bookmark_id` (integer): The ID of the bookmark to retrieve.
142+
143+
**Response:**
144+
- `200 OK`: A JSON object containing the details of the bookmark.
145+
146+
#### Remove Bookmark
147+
148+
**Method:** `RPC`
149+
150+
**Description:** Removes a bookmark by ID.
151+
152+
**Parameters:**
153+
- `key` (string): The key of the bookmark to remove.
154+
155+
**Response:**
156+
- `200 OK`: A success message.
157+
158+
#### Share Bookmark
159+
160+
**Method:** `RPC`
161+
162+
**Description:** Shares a bookmark with specified groups.
163+
164+
**Parameters:**
165+
- `bookmark_uid` (string): The UID of the bookmark to share.
166+
- `group_names` (array): An array of group names to share the bookmark with.
167+
168+
**Response:**
169+
- `200 OK`: A success message.
170+
171+
### User Layers
172+
173+
#### Add User Layer
174+
175+
**Method:** `RPC`
176+
177+
**Description:** Adds a new user layer.
178+
179+
**Parameters:**
180+
- `name` (string): The name of the user layer.
181+
- `description` (string): The description of the user layer.
182+
- `url` (string): The URL of the user layer.
183+
- `layer_type` (string): The type of the user layer.
184+
- `arcgis_layers` (string): The ArcGIS layers of the user layer.
185+
186+
**Response:**
187+
- `200 OK`: A JSON object containing the details of the added user layer.
188+
189+
#### Get User Layers
190+
191+
**Method:** `RPC`
192+
193+
**Description:** Retrieves a list of all user layers for the current user.
194+
195+
**Response:**
196+
- `200 OK`: A JSON array containing the details of all user layers.
197+
198+
#### Load User Layer
199+
200+
**Method:** `RPC`
201+
202+
**Description:** Retrieves a user layer by ID.
203+
204+
**Parameters:**
205+
- `user_layer_id` (integer): The ID of the user layer to retrieve.
206+
207+
**Response:**
208+
- `200 OK`: A JSON object containing the details of the user layer.
209+
210+
#### Remove User Layer
211+
212+
**Method:** `RPC`
213+
214+
**Description:** Removes a user layer by ID.
215+
216+
**Parameters:**
217+
- `key` (string): The key of the user layer to remove.
218+
219+
**Response:**
220+
- `200 OK`: A success message.
221+
222+
#### Share User Layer
223+
224+
**Method:** `RPC`
225+
226+
**Description:** Shares a user layer with specified groups.
227+
228+
**Parameters:**
229+
- `user_layer_uid` (string): The UID of the user layer to share.
230+
- `group_names` (array): An array of group names to share the user layer with.
231+
232+
**Response:**
233+
- `200 OK`: A success message.
234+
235+
## Example Usage
236+
237+
### Add Bookmark
238+
239+
```sh
240+
rpc.call('add_bookmark', {
241+
name: 'Example Bookmark',
242+
description: 'This is an example bookmark.',
243+
url_hash: 'abc123',
244+
json: '{"example": "data"}'
245+
})
246+
```
247+
248+
### Get Bookmarks
249+
250+
```sh
251+
rpc.call('get_bookmarks')
252+
```
253+
254+
### Load Bookmark
255+
256+
```sh
257+
rpc.call('load_bookmark', { bookmark_id: 1 })
258+
```
259+
260+
### Remove Bookmark
261+
262+
```sh
263+
rpc.call('remove_bookmark', { key: 'bookmark_1' })
264+
```
265+
266+
### Share Bookmark
267+
268+
```sh
269+
rpc.call('share_bookmark', {
270+
bookmark_uid: 'bookmark_1',
271+
group_names: ['Group1', 'Group2']
272+
})
273+
```
274+
275+
### Add User Layer
276+
277+
```sh
278+
rpc.call('add_user_layer', {
279+
name: 'Example User Layer',
280+
description: 'This is an example user layer.',
281+
url: 'http://example.com/layer',
282+
layer_type: 'WMS',
283+
arcgis_layers: 'Layer1,Layer2'
284+
})
285+
```
286+
287+
### Get User Layers
288+
289+
```sh
290+
rpc.call('get_user_layers')
291+
```
292+
293+
### Load User Layer
294+
295+
```sh
296+
rpc.call('load_user_layer', { user_layer_id: 1 })
297+
```
298+
299+
### Remove User Layer
300+
301+
```sh
302+
rpc.call('remove_user_layer', { key: 'user_layer_1' })
303+
```
304+
305+
### Share User Layer
306+
307+
```sh
308+
rpc.call('share_user_layer', {
309+
user_layer_uid: 'user_layer_1',
310+
group_names: ['Group1', 'Group2']
311+
})
312+
```
313+
314+
## Notes
315+
316+
- Ensure that you have the necessary permissions to access these endpoints.
317+
- The responses are in JSON format.
318+
- The `bookmark_id` and `user_layer_id` should be valid integers representing existing bookmarks and user layers, respectively.
319+
320+
For further assistance, please contact the support team.

0 commit comments

Comments
 (0)