Location + Land Use Sources

- Add sources to multiple fields on Location + Land Use Categories
- Use data-fields-config properly instead of hard-coding some values
This commit is contained in:
Mike Simpson 2023-05-19 11:55:32 +01:00
parent 715cdfaa02
commit 4e348e7b54
8 changed files with 209 additions and 75 deletions

View File

@ -79,6 +79,14 @@ export const buildingAttributesConfig = valueType<DataFieldConfig>()({ /* eslint
edit: true,
verify: true
},
location_address_source: {
edit: true,
verify: true
},
location_address_links: {
edit: true,
verify: true
},
location_latitude: {
edit: true,
verify: true,
@ -87,6 +95,14 @@ export const buildingAttributesConfig = valueType<DataFieldConfig>()({ /* eslint
edit: true,
verify: true,
},
location_coordinates_source: {
edit: true,
verify: true
},
location_coordinates_links: {
edit: true,
verify: true
},
date_year: {
edit: true,
verify: true,
@ -284,18 +300,24 @@ export const buildingAttributesConfig = valueType<DataFieldConfig>()({ /* eslint
edit: true,
verify: true
},
demolished_buildings: {
edit: true,
verify: false,
asJson: true,
sqlCast: 'jsonb',
},
is_domestic: {
edit: true,
verify: true
},
is_domestic_source: {
edit: true,
verify: true
},
is_domestic_links: {
edit: true,
verify: true
},
survival_status: {
edit: true,
verify: true

View File

@ -38,7 +38,7 @@ const UseView: React.FunctionComponent<CategoryViewProps> = (props) => {
title={dataFields.is_domestic.title}
slug="is_domestic"
value={props.building.is_domestic}
options={["yes", "no", "mixed domestic/non-domestic"]}
options={dataFields.is_domestic.items}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
@ -55,29 +55,30 @@ const UseView: React.FunctionComponent<CategoryViewProps> = (props) => {
<SelectDataEntry
title={dataFields.is_domestic_source.title}
slug="is_domestic_source"
value={props.building.is_domestic}
options={
[
"Expert knowledge",
"Observed from the street",
"Google or other photograph/satellite imagery",
"Government/public record/database",
"Independently managed record/database",
"Other type of record/database"
]
}
value={props.building.is_domestic_source}
options={dataFields.is_domestic_source.items}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.is_domestic_source.tooltip}
/>
<DataEntry
title="Source link"
slug=""
value=""
mode='view'
tooltip="Coming Soon"
{(props.building.is_domestic_source == "Expert knowledge" ||
props.building.is_domestic_source == "Observed from the street" ||
props.building.is_domestic_source == null) ? <></> :
<><MultiDataEntry
title={dataFields.is_domestic_links.title}
slug="is_domestic_links"
value={props.building.is_domestic_links}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.is_domestic_links.tooltip}
placeholder="https://..."
editableEntries={true}
isUrl={true}
/>
</>
}
</DataEntryGroup>
<DataEntryGroup name="Specific land use data">
<MultiDataEntry

View File

@ -1,6 +1,4 @@
import React, { Fragment } from 'react';
import InfoBox from '../../components/info-box';
import { dataFields } from '../../config/data-fields-config';
import DataEntry from '../data-components/data-entry';
import NumericDataEntry from '../data-components/numeric-data-entry';
@ -8,15 +6,15 @@ import UPRNsDataEntry from '../data-components/uprns-data-entry';
import Verification from '../data-components/verification';
import withCopyEdit from '../data-container';
import { PatternDataEntry } from '../data-components/pattern-data-entry';
import { CategoryViewProps } from './category-view-props';
import { DataEntryGroup } from '../data-components/data-entry-group';
import SelectDataEntry from '../data-components/select-data-entry';
import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry';
const locationNumberPattern = "[1-9]\\d*[a-z]?(-([1-9]\\d*))?"; ///[1-9]\d*[a-z]?(-([1-9]\d*))?/;
const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
<Fragment>
<DataEntryGroup name="Address data">
<DataEntry
title={dataFields.location_name.title}
@ -44,21 +42,6 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
mode='view'
tooltip="Not yet activated.<br><br>For security reasons, we do not allow the use of free text boxes and are currently looking into alternative ways to collect this data."
/>
<Verification
slug="location_name"
allow_verify={props.user !== undefined && props.building.location_name !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("location_name")}
user_verified_as={props.user_verified.location_name}
verified_count={props.building.verified.location_name}
/>
<DataEntry
title="Source"
slug=""
value=""
mode='view'
tooltip="Coming Soon"
/>
<hr/>
<PatternDataEntry
title={dataFields.location_number.title}
@ -137,7 +120,6 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
onChange={props.onChange}
maxLength={8}
valueTransform={x=>x.toUpperCase()}
/>
<Verification
slug="location_postcode"
@ -147,13 +129,35 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
user_verified_as={props.user_verified.location_postcode}
verified_count={props.building.verified.location_postcode}
/>
<DataEntry
title="Source"
slug=""
value=""
mode='view'
tooltip="Coming Soon"
<SelectDataEntry
title={dataFields.location_address_source.title}
slug="location_address_source"
value={props.building.location_address_source}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.location_address_source.tooltip}
placeholder={dataFields.location_address_source.example}
options={dataFields.location_address_source.items}
/>
{(props.building.location_address_source == "Expert/personal knowledge of building" ||
props.building.location_address_source == "Online streetview image" ||
props.building.location_address_source == null) ? <></> :
<>
<MultiDataEntry
title={dataFields.location_address_links.title}
slug="location_address_links"
value={props.building.location_address_links}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.location_address_links.tooltip}
placeholder="https://..."
editableEntries={true}
isUrl={true}
/>
</>
}
</DataEntryGroup>
<DataEntryGroup name="Property/footprint IDs and coordinate data">
<DataEntry
@ -233,13 +237,35 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
user_verified_as={props.user_verified.location_longitude}
verified_count={props.building.verified.location_longitude}
/>
<DataEntry
title="Source"
slug=""
value=""
mode='view'
tooltip="Coming Soon"
<SelectDataEntry
title={dataFields.location_coordinates_source.title}
slug="location_coordinates_source"
value={props.building.location_coordinates_source}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.location_coordinates_source.tooltip}
placeholder={dataFields.location_coordinates_source.example}
options={dataFields.location_coordinates_source.items}
/>
{(props.building.location_coordinates_source == "Expert/personal knowledge of building" ||
props.building.location_coordinates_source == "Online streetview image" ||
props.building.location_coordinates_source == null) ? <></> :
<>
<MultiDataEntry
title={dataFields.location_coordinates_links.title}
slug="location_coordinates_links"
value={props.building.location_coordinates_links}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.location_coordinates_links.tooltip}
placeholder="https://..."
editableEntries={true}
isUrl={true}
/>
</>
}
</DataEntryGroup>
</Fragment>
);

View File

@ -163,6 +163,27 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
example: "W1W 6TR",
//tooltip: ,
},
location_address_source: {
category: Category.Location,
title: "Source",
example: "",
tooltip: "Source of address data.",
items: [
"Expert/personal knowledge of building",
"Online streetview image",
"Open planning authority dataset",
"Open property tax dataset",
"Open housing dataset",
"Open address dataset",
"Other"
]
},
location_address_links: {
category: Category.Location,
title: "Source link(s)",
tooltip: "URL(s) for building address data source(s).",
example: ["", "", ""],
},
ref_toid: {
category: Category.Location,
title: "Building footprint ID",
@ -209,6 +230,27 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
tooltip: "Longitude of building centroid",
example: 0.12124,
},
location_coordinates_source: {
category: Category.Location,
title: "Source",
example: "",
tooltip: "Source of lcoordinate data.",
items: [
"Expert/personal knowledge of building",
"Online streetview image",
"Open planning authority dataset",
"Open property tax dataset",
"Open housing dataset",
"Open address dataset",
"Other"
]
},
location_coordinates_links: {
category: Category.Location,
title: "Source link(s)",
tooltip: "URL(s) for building coordinate data source(s).",
example: ["", "", ""],
},
current_landuse_group: {
category: Category.LandUse,
title: "Current land use(s)",
@ -223,7 +265,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
},
current_landuse_source: {
category: Category.LandUse,
title: "Source of information",
title: "Source type",
tooltip: "Source for the current land use",
example: "",
items: [
@ -244,8 +286,8 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
},
current_landuse_link: {
category: Category.LandUse,
title: "Source links",
tooltip: "URL for current land use reference",
title: "Source link(s)",
tooltip: "URL(s) for current land use reference",
example: ["", "", ""],
},
current_landuse_verified: {
@ -602,13 +644,32 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
category: Category.Team,
title: "Is the building a home/domestic building?",
tooltip: "Note: Homes used as offices for working from home should be classified as domestic.",
example: "mixed domestic/non-domestic"
example: "mixed domestic/non-domestic",
items: [
"Yes",
"No",
"Mixed domestic/non-domestic"
]
},
is_domestic_source: {
category: Category.Team,
title: "Source type",
tooltip: "",
example: ""
tooltip: "Source of domestic/non-domestic data",
example: "",
items: [
"Expert knowledge",
"Observed from the street",
"Google or other photograph/satellite imagery",
"Government/public record/database",
"Independently managed record/database",
"Other type of record/database"
]
},
is_domestic_links: {
category: Category.Team,
title: "Source links",
tooltip: "URL(s) for domestic/non-domestic data source(s)",
example: ["", "", ""],
},
likes_total: {
category: Category.Community,
@ -705,7 +766,8 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
{
year_constructed: { min: 1989, max: 1991 },
year_demolished: { min: 1993, max: 1994 },
lifespan: "2-5", overlap_present: "50%", links: ["", ""]}
lifespan: "2-5", overlap_present: "50%", links: ["", ""]
}
]
},
has_extension: {

View File

@ -39,8 +39,12 @@ This is the main table, containing almost all data collected by Colouring London
- `location_line_two`: additional address line
- `location_town`: town
- `location_postcode`: postcode
- `location_address_source`: type of source used for address data
- `location_address_links`: link to source used for address data
- `location_latitude`: latitude
- `location_longitude`: longitude
- `location_coordinates_source`: source type of coordinate data
- `location_coordinates_links`: source links for coordinate data
- `current_landuse_group`: current land use group
- `current_landuse_order`: current land use order
- `building_attachment_form`: building attachment form
@ -85,6 +89,9 @@ This is the main table, containing almost all data collected by Colouring London
- `planning_local_list_url`: local list reference link
- `planning_historic_area_assessment_url`: historic area assessment reference link
- `likes_total`: number of times the building has been liked by Colouring London users
- `is_domestic`: is the building domestic/non-domestic/mixed
- `is_domestic_source`: domestic data source type,
-`is_domestic_links`: domestic data source links,
## Building UPRNs

View File

@ -9,6 +9,8 @@ COPY (SELECT
location_line_two,
location_town,
location_postcode,
location_address_source,
location_address_links,
location_latitude,
location_longitude,
current_landuse_group,
@ -55,6 +57,8 @@ COPY (SELECT
planning_local_list_url,
planning_historic_area_assessment_url,
is_domestic,
is_domestic_source,
is_domestic_links,
community_type_worth_keeping_total,
likes_total,
survival_status,

View File

@ -0,0 +1,6 @@
ALTER TABLE buildings DROP COLUMN IF EXISTS location_address_source;
ALTER TABLE buildings DROP COLUMN IF EXISTS location_address_links;
ALTER TABLE buildings DROP COLUMN IF EXISTS location_coordinates_source;
ALTER TABLE buildings DROP COLUMN IF EXISTS location_coordinates_links;
ALTER TABLE buildings DROP COLUMN IF EXISTS is_domestic_source;
ALTER TABLE buildings DROP COLUMN IF EXISTS is_domestic_links;

View File

@ -0,0 +1,6 @@
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_address_source text;
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_address_links text[];
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_coordinates_source text;
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_coordinates_links text[];
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS is_domestic_source text;
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS is_domestic_links text[];