Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit 73f78ed

Browse files
Add routes for retrieving vector data (#128)
* Add routes * some linting * Disable get and select for GeoResourceProxy * typo Co-authored-by: Kevin Richter <[email protected]>
1 parent 9c495cd commit 73f78ed

File tree

5 files changed

+123
-3
lines changed

5 files changed

+123
-3
lines changed

src/Maps4News.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ import {
6868
Tag,
6969
TagType,
7070
User,
71+
VectorHighlight,
72+
VectorChoropleth,
7173
} from './resources';
7274
import ResourceBase from './resources/base/ResourceBase';
7375
import Injectable from './traits/Injectable';
@@ -315,7 +317,16 @@ export default class Maps4News extends mix(null, Injectable) {
315317
* @returns {GeoResourceProxy} - A proxy for accessing the resource
316318
*/
317319
get choropleths () {
318-
return new GeoResourceProxy(this, Choropleth, null, {}, {});
320+
return new GeoResourceProxy(this, Choropleth);
321+
}
322+
323+
/**
324+
* VectorChoropleth accessor
325+
* @see {@link VectorChoropleth}
326+
* @returns {GeoResourceProxy} - A proxy for accessing the resource
327+
*/
328+
get vectorChoropleths () {
329+
return new GeoResourceProxy(this, VectorChoropleth);
319330
}
320331

321332
/**
@@ -423,7 +434,16 @@ export default class Maps4News extends mix(null, Injectable) {
423434
* @returns {GeoResourceProxy} - A proxy for accessing the resource
424435
*/
425436
get highlights () {
426-
return new GeoResourceProxy(this, Highlight, null, {}, {});
437+
return new GeoResourceProxy(this, Highlight);
438+
}
439+
440+
/**
441+
* VectorHighlight accessor
442+
* @see {@link VectorHighlight}
443+
* @returns {GeoResourceProxy} - A proxy for accessing the resource
444+
*/
445+
get vectorHighlights () {
446+
return new GeoResourceProxy(this, VectorHighlight);
427447
}
428448

429449
/**
@@ -432,7 +452,7 @@ export default class Maps4News extends mix(null, Injectable) {
432452
* @returns {GeoResourceProxy} - A proxy for accessing the resource
433453
*/
434454
get insetMaps () {
435-
return new GeoResourceProxy(this, InsetMap, null, {}, {});
455+
return new GeoResourceProxy(this, InsetMap);
436456
}
437457

438458
/**

src/proxy/GeoResourceProxy.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,22 @@ export default class GeoResourceProxy extends ResourceProxy {
127127

128128
return result.map(r => this.new(r));
129129
}
130+
131+
/**
132+
* Stub implementation of the get method
133+
* Geographic resources don't have stable IDs so we can not reference them by ID
134+
* @throws TypeError
135+
*/
136+
get () {
137+
throw new TypeError('Geographic resources do not support IDs');
138+
}
139+
140+
/**
141+
* Stub implementation of the select method
142+
* Geographic resources don't have stable IDs so we can not reference them by ID
143+
* @throws TypeError
144+
*/
145+
select () {
146+
throw new TypeError('Geographic resources do not support IDs');
147+
}
130148
}

src/resources/VectorChoropleth.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* BSD 3-Clause License
3+
*
4+
* Copyright (c) 2020, Mapcreator
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* Redistributions of source code must retain the above copyright notice, this
11+
* list of conditions and the following disclaimer.
12+
*
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived from
19+
* this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
34+
import ResourceBase from './base/ResourceBase';
35+
36+
export default class VectorChoropleth extends ResourceBase {
37+
static get resourceName () {
38+
return 'choropleths/vector';
39+
}
40+
}

src/resources/VectorHighlight.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* BSD 3-Clause License
3+
*
4+
* Copyright (c) 2020, Mapcreator
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* Redistributions of source code must retain the above copyright notice, this
11+
* list of conditions and the following disclaimer.
12+
*
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived from
19+
* this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
34+
import ResourceBase from './base/ResourceBase';
35+
36+
export default class VectorHighlight extends ResourceBase {
37+
static get resourceName () {
38+
return 'highlights/vector';
39+
}
40+
}

src/resources/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export SvgSet from './SvgSet';
6161
export Tag from './Tag';
6262
export TagType from './TagType';
6363
export User from './User';
64+
export VectorHighlight from './VectorHighlight';
65+
export VectorChoropleth from './VectorChoropleth';
6466

6567
import CrudBase from './base/CrudBase';
6668
import CrudSetBase from './base/CrudSetBase';

0 commit comments

Comments
 (0)