Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement some Australian parking signs and presets #44

Closed
wants to merge 5 commits into from
Closed
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ Viewer:
Editor:

<img src="https://i.imgur.com/e0vsqUQ.png" alt="Editor UI">

# Local Development

- Install dependencies: `npm install`
- Start Webpack dev server: `npm run start`

Geolocation won't work over http. [ngrok](https://ngrok.com/docs) can start an HTTPS tunnel to your
localhost with the following command:

`ngrok http --host-header=rewrite 33444`
Binary file added src/.DS_Store
Binary file not shown.
54 changes: 35 additions & 19 deletions src/parking/controls/editor/editor-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ function getSideGroup(osm, side) {
return hyper`
<div id=${side}
class="tags-block_${side}">
${getPresetSigns(osm, side)}
<div>
<span><b>Russia</b></span>
${getPresetSigns(osm, side, 'russia')}
</div>
<div>
<span><b>Australia</b></span>
${getPresetSigns(osm, side, 'australia')}
</div>

<table>
${getTagInupts(osm, side)}
</table>
Expand All @@ -80,27 +88,31 @@ const parkingLaneTagTemplates = [
'parking:lane:{side}',
'parking:lane:{side}:{type}',
'parking:condition:{side}',
'parking:condition:{side}:time_interval',
'parking:condition:{side}:default',
'parking:condition:{side}:time_interval',
'parking:condition:{side}:maxstay',
'parking:condition:{side}:capacity',
'parking:condition:{side}:residents',
'parking:condition:{side}:disc:time_interval',
'parking:condition:{side}:disc:maxstay',
]

function getTagInupts(osm, side) {
const inputs = []
const type = osm.tags[`parking:lane:${side}`] || 'type'
for (const tagTemplate of parkingLaneTagTemplates)
inputs.push(getTagInupt(osm, side, type, tagTemplate))
inputs.push(getTagInput(osm, side, type, tagTemplate))
return inputs
}

function getTagInupt(osm, side, parkingType, tagTemplate) {
function getTagInput(osm, side, parkingType, tagTemplate) {
const tag = tagTemplate
.replace('{side}', side)
.replace('{type}', parkingType)

const tagSplit = tag.split(':')
const label = tagSplit[Math.floor(tagSplit.length / 2) * 2 - 1]
// Show the entire tag. If we cut by `:` then tags with multiple
// `:` aren't shown correctly.
const label = tag

const value = osm.tags[tag]

Expand Down Expand Up @@ -134,9 +146,8 @@ function getTagInupt(osm, side, parkingType, tagTemplate) {

case 'parking:condition:{side}:default': {
input = getTextInput(tag, value)
const timeIntervalTag = 'parking:condition:{side}:time_interval'
.replace('{side}', side)
hide = !osm.tags[timeIntervalTag]
// Don't hide this even if time_interval is showing -
// the default is still important
break
}
case 'parking:condition:{side}:maxstay': {
Expand Down Expand Up @@ -178,22 +189,27 @@ function getSelectInput(tag, value, values) {
}

function getTextInput(tag, value) {
const placeholder = tag.includes(':residents') ? '* for any OR permit #' : tag

return hyper`
<input type="text"
placeholder="${tag}"
placeholder="${placeholder}"
name="${tag}"
value="${value != null ? value : ''}">`
}

function getPresetSigns(osm, side) {
return presets.map(x => hyper`
<img src=${x.img.src}
class="sign-preset"
height=${x.img.height}
width=${x.img.width}
alt=${x.img.alt}
title=${x.img.title}
onclick=${() => handlePresetClick(x.tags, osm, side)}>`)
function getPresetSigns(osm, side, country) {
return presets
// Filter signs by that country
.filter(preset => preset.country === country)
.map(x => hyper`
<img src=${x.img.src}
class="sign-preset"
height=${x.img.height}
width=${x.img.width}
alt=${x.img.alt}
title=${x.img.title}
onclick=${() => handlePresetClick(x.tags, osm, side)}>`)
}

function handlePresetClick(tags, osm, side) {
Expand Down
151 changes: 145 additions & 6 deletions src/parking/controls/editor/presets.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,136 @@

import ausNoStoppingImg from '../../../signs/no-stopping.jpg'
import ausNoParkingSign from '../../../signs/no-parking.jpg'
import aus1pSign from '../../../signs/1p.jpg'
import aus1pDuringDaySign from '../../../signs/1p-during-day.jpg'
import aus2pPermitSign from '../../../signs/2p-permit.png'

const ausSignWidth = 30
const ausSignAspectRatio = 60 / 100
const ausSignHeight = ausSignWidth / ausSignAspectRatio

export const presets = [
{
country: 'australia',
key: 'noStoppingAus',
tags: [
{ k: 'parking:lane:{side}', v: 'no_stopping' },
{ k: 'parking:condition:{side}', v: '' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: ausNoStoppingImg,
height: ausSignHeight,
width: ausSignWidth,
alt: 'No Stopping Sign',
title: 'No Stopping',
},
},
{
country: 'australia',
key: 'noParkingAus',
tags: [
{ k: 'parking:lane:{side}', v: 'no_parking' },
{ k: 'parking:condition:{side}', v: '' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: ausNoParkingSign,
height: ausSignHeight,
width: ausSignWidth,
alt: 'No Parking Sign',
title: 'No Parking',
},
},
{
country: 'australia',
key: '1p-during-day',
tags: [
{ k: 'parking:lane:{side}', v: '' },
{ k: 'parking:condition:{side}', v: 'disc' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: 'free' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '1 hour' },
{ k: 'parking:condition:{side}:disc:time_interval', v: 'Mo-Fr 09:30-17:30; Sa 09:00-12:00' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {

src: aus1pDuringDaySign,
height: ausSignHeight,
width: ausSignWidth,
alt: '1P free parking during day, unlimited otherwise',
title: '1P free parking during day, unlimited otherwise',
},
click: {
showTypeButtons: true,
},
},
{
country: 'australia',
key: '1p',
tags: [
{ k: 'parking:lane:{side}', v: '' },
{ k: 'parking:condition:{side}', v: 'disc' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '1 hour' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: aus1pSign,
height: ausSignHeight,
width: ausSignWidth,
alt: '1P Parking',
title: '1P free parking',
},
click: {
showTypeButtons: true,
},
},
{
country: 'australia',
key: '2p-residents',
tags: [
{ k: 'parking:lane:{side}', v: '' },
{ k: 'parking:condition:{side}', v: 'disc' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: 'free' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '2 hours' },
{ k: 'parking:condition:{side}:disc:time_interval', v: 'Mo-Fr 08:00-18:00' },
{ k: 'parking:condition:{side}:residents', v: '*' },
],
img: {
src: aus2pPermitSign,
height: ausSignHeight,
width: ausSignWidth,
alt: '2P free parking during weekday daytime, permit excepted',
title: '2P free parking during weekday daytime, permit excepted',
},
click: {
showTypeButtons: true,
},
},
{
country: 'russia',
key: 'noStopping',
tags: [
{ k: 'parking:lane:{side}', v: 'no_stopping' },
{ k: 'parking:condition:{side}', v: '' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: 'https://upload.wikimedia.org/wikipedia/commons/9/98/3.27_Russian_road_sign.svg',
Expand All @@ -17,13 +141,16 @@ export const presets = [
},
},
{
country: 'russia',
key: 'noParking',
tags: [
{ k: 'parking:lane:{side}', v: 'no_parking' },
{ k: 'parking:condition:{side}', v: '' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: 'https://upload.wikimedia.org/wikipedia/commons/8/81/3.28_Russian_road_sign.svg',
Expand All @@ -34,13 +161,16 @@ export const presets = [
},
},
{
country: 'russia',
key: 'noParkingOdd',
tags: [
{ k: 'parking:lane:{side}', v: 'no_parking' },
{ k: 'parking:condition:{side}', v: '' },
{ k: 'parking:condition:{side}:time_interval', v: '1-31/2' },
{ k: 'parking:condition:{side}:default', v: 'free' },
{ k: 'parking:condition:{side}:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: 'https://upload.wikimedia.org/wikipedia/commons/f/f4/3.29_Russian_road_sign.svg',
Expand All @@ -51,13 +181,16 @@ export const presets = [
},
},
{
country: 'russia',
key: 'noParkingEven',
tags: [
{ k: 'parking:lane:{side}', v: 'no_parking' },
{ k: 'parking:condition:{side}', v: '' },
{ k: 'parking:condition:{side}:time_interval', v: '2-30/2' },
{ k: 'parking:condition:{side}:default', v: 'free' },
{ k: 'parking:condition:{side}:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: 'https://upload.wikimedia.org/wikipedia/commons/7/76/3.30_Russian_road_sign.svg',
Expand All @@ -68,13 +201,16 @@ export const presets = [
},
},
{
country: 'russia',
key: 'parking',
tags: [
{ k: 'parking:lane:{side}', v: '' },
{ k: 'parking:condition:{side}', v: 'free' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: 'https://upload.wikimedia.org/wikipedia/commons/e/eb/6.4_Russian_road_sign.svg',
Expand All @@ -88,13 +224,16 @@ export const presets = [
},
},
{
country: 'russia',
key: 'ticket',
tags: [
{ k: 'parking:lane:{side}', v: '' },
{ k: 'parking:condition:{side}', v: 'ticket' },
{ k: 'parking:condition:{side}:time_interval', v: '' },
{ k: 'parking:condition:{side}:default', v: '' },
{ k: 'parking:condition:{side}:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:maxstay', v: '' },
{ k: 'parking:condition:{side}:disc:time_interval', v: '' },
{ k: 'parking:condition:{side}:residents', v: '' },
],
img: {
src: 'https://upload.wikimedia.org/wikipedia/commons/f/f3/8.8_Russian_road_sign.svg',
Expand Down
2 changes: 1 addition & 1 deletion src/parking/controls/lane-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default L.Control.extend({
function getPanel(osm, body) {
return hyper`
<div>
<div style="min-width:250px">
<div style="min-width:300px">
<a href="https://openstreetmap.org/way/${osm.id}" target="_blank">View in OSM</a>
<span style="float:right">
Edit:
Expand Down
Binary file added src/signs/1p-during-day.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/signs/1p.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/signs/2p-permit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/signs/no-parking.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/signs/no-stopping.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions taginfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
{ "key": "parking:condition:right:time_interval", "object_types": ["way"] },
{ "key": "parking:condition:both:time_interval", "object_types": ["way"] },

{ "key": "parking:condition:left:disc:time_interval", "object_types": ["way"] },
{ "key": "parking:condition:right:disc:time_interval", "object_types": ["way"] },
{ "key": "parking:condition:both:disc:time_interval", "object_types": ["way"] },

{ "key": "parking:condition:left:default", "object_types": ["way"] },
{ "key": "parking:condition:right:default", "object_types": ["way"] },
{ "key": "parking:condition:both:default", "object_types": ["way"] },
Expand Down