joelondon f346c83497 | 3 years ago | |
---|---|---|
.standard-cache | 5 years ago | |
public | 3 years ago | |
src | 4 years ago | |
.babel.json | 5 years ago | |
.babelrc | 5 years ago | |
.gitignore | 4 years ago | |
.glitch-assets | 4 years ago | |
.prettierrc | 4 years ago | |
.v8flags.6.2.414.75.d41d8cd98f00b204e9800998ecf8427e.json | 4 years ago | |
.wget-hsts | 4 years ago | |
CODE_OF_CONDUCT.md | 5 years ago | |
README.md | 4 years ago | |
gulpfile.js | 5 years ago | |
package-lock.json | 4 years ago | |
package.json | 4 years ago | |
server.js | 4 years ago | |
shrinkwrap.yaml | 4 years ago |
small_site_suggestions_service_01
user submissions, in the form of points (or boundaries)
{
"Site Ref": "auto",
"Site Name / Description": "eg site next to school playground",
"Ideas and Suggestions": "Why have you have suggested this location? How could it be developed? Do you have a local connection?",
"Capacity": "Roughly, how many homes could fit here?",
"Postcode": "",
"Borough": "",
"Lat": "",
"Long": "",
"Acres": "",
"Hectares": "",
"Contact email": "In case we need to follow-up with you",
"Would you be in a position to develop this site?": "y/n",
"Date Submitted": ""
}
this service accepts user added features
during testing, to clear all features - run the following curl command:
curl 'https://maps.london.gov.uk/gla/rest/services/apps/small_site_suggestions_service_01/FeatureServer/0/deleteFeatures' -H 'Cookie: __cfduid=d056efa5ddcb722fe9b3c6ac78a71e3351512140697' -H 'Origin: https://maps.london.gov.uk' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36 OPR/49.0.2725.39' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: https://maps.london.gov.uk/gla/rest/services/apps/small_site_suggestions_service_01/FeatureServer/0/deleteFeatures' -H 'Connection: keep-alive' --data 'objectIds=&where=1%3D1&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&gdbVersion=&rollbackOnFailure=true&f=json' --compressed ;
note the london.gov.uk servers running the page that embeds this have enabled cors for this traffic
previously we had considered a server side proxy written in python or node
this is a very simple node app using express for a little routing via server.js
this app is written in ES6, and uses babel to output ES5 compatible js (for IE11)
it uses a simple .babelrc
which just removes the use strict
directive and chooses ES5 (env
preset)
{
"presets": [
["env", { "modules": false }]
]
}
note some ES6 features such as for...of
are not transferable without additional polyfills configured; one solution is to just use an old fashioned i indexed for loop
this app also uses gulpfile.js
to copy html and js from the src
to public
directory, changing the link accordingly (use the gulp deploy
command)
standard is used to lint js and apply some of its code conventions
js-beautify is used to indent (ideally a tab is two spaces but this isn't configured here)
package.json
is how the packages are coordinated by npm, which also determines the autostart option and project metadata
"start": "babel public/js -d public/babel && gulp deploy && node server.js"
features to archived on an ad hoc basis in cooperation with team
map service from arcgis server
http://geojson.io/#id=gist:joelondon/f4981ba03a6808112112462ca9830e0d&map=4/51.47/25.85
Presented in lat/lon, web mercator (undeclared) projection or EPSG:3785 (osm) or EPSG:4326 (leaflet)
NOTE the first image in field_small_site_images
(carousel list) is the one to show in the popup.
{
type: "Feature",
-geometry: {
type: "Point",
-coordinates: (2)[
0.1784,
51.4184
]
},
-properties: {
name: "Cook Road Junction - Plot 001",
description: "Vacant tarmacked plot opposite Colliers Wood tube station...",
nid: 40631,
path: https://wwwtest.london.gov.uk/what-we-do/housing-and-land/land-and-development/small-sites-small-builders/cook-road-junction-plot,
field_hero_image: https://wwwtest.london.gov.uk/sites/default/files/styles/gla_2_1_medium/public/trees_carbon.jpeg?itok=0UyArHGL,
field_ideal_for: "A small high quality scheme with commercial space",
field_short_title: "Plot001 - 0.08",
field_site_acres: 0.08,
field_site_address: "194-194 High Street, Colliers Wood, SW19 2BN",
field_site_borough: "Barking and Dagenham",
field_site_landowner: "Transport for London / London Underground Ltd (freehold)",
field_site_reference: "P001",
field_site_sites_type: null,
field_site_status: "Submit by",
field_small_site_images: "https://wwwtest.london.gov.uk/sites/default/files/styles/gla_2_1_medium/public/river-lea_0.jpg?itok=SgdvMh_O, https://wwwtest.london.gov.uk/sites/default/files/styles/gla_2_1_medium/public/aerial-tower-bridge.jpg?itok=ZW8uklDV, https://wwwtest.london.gov.uk/sites/default/files/styles/gla_2_1_medium/public/birdseye_view.jpg?itok=vVsKmmAy, https://wwwtest.london.gov.uk/sites/default/files/styles/gla_2_1_medium/public/city2520hall2520at2520night_jpg.jpg?itok=XHn3f2sr",
field_submission_closing_date: "2017-10-17 15:04:00"
}
}