Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

feat: use arcgis FCC data #154

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,30 @@ It correctly bundles React in production mode and optimizes the build for the be
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

## Data source

Run the following command to fetch updated data from the data source.

```
yarn update:datasource
```

The [fcc.json](./src/datasource/generated/fcc.json) file is fetched from the following url:

```
https://services9.arcgis.com/8svDug0pVvBQzXWS/arcgis/rest/services/GB_FCC_STANOVISTE/FeatureServer/0/query
?f=json
&where=1%3D1
&returnGeometry=true
&spatialRel=esriSpatialRelIntersects
&outFields=*
&maxRecordCountFactor=4
&outSR=4326
&resultOffset=0
&resultRecordCount=8000
&cacheHint=true
```

The endpoint was found at the [official map](https://c-budejovice.maps.arcgis.com/apps/webappviewer/index.html?id=e41744713ec44ce786a797a7e5fd8057).
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "yarn install && vite",
"build": "tsc && vite build",
"serve": "vite preview",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"update:datasource": "node scripts/update_fcc"
},
"dependencies": {
"clsx": "1.1.1",
Expand Down
17 changes: 17 additions & 0 deletions scripts/update_fcc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const https = require("https"); // or 'https' for https:// URLs
const fs = require("fs");

const url = `https://services9.arcgis.com/8svDug0pVvBQzXWS/arcgis/rest/services/GB_FCC_STANOVISTE/FeatureServer/0/query
?f=json
&where=1%3D1
&returnGeometry=true
&spatialRel=esriSpatialRelIntersects
&outFields=*
&maxRecordCountFactor=4
&outSR=4326
&resultOffset=0
&resultRecordCount=8000
&cacheHint=true`;

const file = fs.createWriteStream("./src/datasource/generated/fcc.json");
https.get(url, (response) => response.pipe(file));
7 changes: 4 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Filters } from "components/Filters";
import { IconSpot } from "components/IconSpot";
import { LeafletCluster } from "components/LeafletCluster";
import { Map } from "components/Map";
import { IconSpot } from "components/IconSpot";
import { Filters as TFilters, getSpots, Spot } from "datasource";
import { marker, divIcon, Marker, LatLng } from "leaflet";
import { getSpots } from "datasource";
import { Filters as TFilters, Spot } from "datasource/types";
import { divIcon, LatLng, marker, Marker } from "leaflet";
import { FC, useCallback, useEffect, useMemo, useState } from "react";
import { renderToStaticMarkup } from "react-dom/server";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Filters.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CheckBox } from "components/CheckBox";
import { ContainerType, Filters as TFilters } from "datasource";
import { ContainerType, Filters as TFilters } from "datasource/types";
import { useCallback } from "react";
import { containerTypeKeys, containerTypes } from "utils/container";

Expand Down
2 changes: 1 addition & 1 deletion src/components/IconSpot.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from "clsx";
import { Icon } from "components/Icon";
import { Container } from "datasource";
import { Container } from "datasource/types";
import { containerTypes } from "utils/container";

type Props = {
Expand Down
19 changes: 7 additions & 12 deletions src/datasource/__snapshots__/generatedDatasource.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@
exports[`properly maps spots and containers 1`] = `
Array [
Object {
"address": "A. Trägera 266/113",
"address": "Plzeňská 608/71, naproti",
"containers": Array [
Object {
"clearDay": "úterý",
"type": "Papír",
"uid": "t1",
},
Object {
"clearDay": "pátek, úterý",
"type": "Kovy",
"uid": "t2",
"clearDay": "středa",
"type": "Plast",
"uid": "1",
},
],
"location": Object {
"latitude": 49.005944075539205,
"longitude": 14.476660503581881,
"latitude": 48.990644999,
"longitude": 14.463385,
},
"uid": "0cbcb8b2-7de5-4603-bc9a-da5b699d9172",
"uid": "Plzeňská 608/71, naproti",
},
]
`;
1 change: 1 addition & 0 deletions src/datasource/generated/fcc.json

Large diffs are not rendered by default.

Loading