Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into sos/jsondiffpatch
  • Loading branch information
sarahscott committed Aug 13, 2021
2 parents 64ba031 + 3f22ace commit 1399125
Show file tree
Hide file tree
Showing 45 changed files with 1,757 additions and 852 deletions.
20 changes: 19 additions & 1 deletion api.planx.uk/gis/local_authorities/canterbury.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function search(

// For this location, iterate through our planning constraints and aggregate/format the responses
async function go(x, y, extras) {
const point = bufferPoint(x, y, 0.05);
const point = bufferPoint(x, y, 0.25);

try {
const results = await Promise.all(
Expand Down Expand Up @@ -91,6 +91,24 @@ async function go(x, y, extras) {
}
);

// Since we have multiple article 4 layers, account for granularity & ensure root variable is synced with the subvariable
if (ob["article4.canterbury.hmo"].value && !ob["article4"].value) {
ob["article4"] = ob["article4.canterbury.hmo"];
// Remove "text" and other keys from subvariable so it doesn't render as separate entry in planning constraints list
ob["article4.canterbury.hmo"] = { value: true };
} else if (!ob["article4.canterbury.hmo"].value) {
// Same as above, make sure we render single a4 planning constraint
ob["article4.canterbury.hmo"] = { value: false };
}

// Merge Listed Buildings & "Locally Listed Buildings" responses under single "listed" variable
if (ob["listed.local"].value && !ob["listed"].value) {
ob["listed"] = ob["listed.local"];
delete ob["listed.local"];
} else if (!ob["listed.local"].value) {
delete ob["listed.local"];
} // If both are true, show each in planning constraints list for MVP debugging; flow schemas only care if passport has "listed"

// Add summary "designated" key to response
const obWithDesignated = addDesignatedVariable(ob);

Expand Down
34 changes: 29 additions & 5 deletions api.planx.uk/gis/local_authorities/lambeth.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,38 @@ async function go(x, y, extras) {
: false,
};

// Since we have multiple article 4 layers, account for granularity & ensure root variable is synced with the subvariable
if (ob["article4.lambeth.kiba"].value && !ob["article4"].value) {
// Since we have multiple article 4 layers, account for granularity & ensure root variable is synced with the subvariables
// We remove "text" & other keys from subvariables so they don't render a seperate entries in planning constraints list
if (
!ob["article4"].value &&
ob["article4.lambeth.kiba"].value &&
ob["article4.lambeth.caz"].value
) {
ob["article4"] = ob["article4.lambeth.kiba"]; // doesn't matter which subvariable properties are stored as root for now
ob["article4.lambeth.kiba"] = { value: true };
ob["article4.lambeth.caz"] = { value: true };
} else if (
!ob["article4"].value &&
!ob["article4.lambeth.kiba"].value &&
ob["article4.lambeth.caz"].value
) {
ob["article4"] = ob["article4.lambeth.caz"];
ob["article4.lambeth.caz"] = { value: true };
ob["article4.lambeth.kiba"] = { value: false };
} else if (
!ob["article4"].value &&
ob["article4.lambeth.kiba"].value &&
!ob["article4.lambeth.caz"].value
) {
ob["article4"] = ob["article4.lambeth.kiba"];
// Remove "text" and other keys from subvariable so it doesn't render as separate entry in planning constraints list
ob["article4.lambeth.kiba"] = { value: true };
} else if (!ob["article4.lambeth.kiba"].value) {
// Same as above, make sure we render single a4 planning constraint
ob["article4.lambeth.caz"] = { value: false };
} else if (
!ob["article4.lambeth.kiba"].value &&
!ob["article4.lambeth.caz"].value
) {
ob["article4.lambeth.kiba"] = { value: false };
ob["article4.lambeth.caz"] = { value: false };
}

// Add summary "designated" key to response
Expand Down
144 changes: 125 additions & 19 deletions api.planx.uk/gis/local_authorities/metadata/canterbury.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,90 @@ const planningConstraints = {
article4: {
key: "article4",
source: canterburyDomain,
id: "External/Heritage",
serverIndex: 9,
fields: ["OBJECTID", "LOCATION_1", "DESCRIPTIO"],
neg: "is not subject to any Article 4 Restriction",
id: "External/Planning_Constraints_New",
serverIndex: 3,
fields: ["OBJECTID", "REF", "LOCATION_1", "COMMENT", "DESCRIPTIO"],
neg: "is not subject to any Article 4 Restrictions",
pos: (data) => ({
text: "is subject to Article 4 Restriction(s)",
description: data.LOCATION_1,
}),
records: {
0: "article4.canterbury.adisham.a",
1: "article4.canterbury.adisham.b",
2: "article4.canterbury.barham.a",
3: "article4.canterbury.barham.b",
4: "article4.canterbury.barham.c",
5: "article4.canterbury.bishopsbourne",
6: "article4.canterbury.blean.a",
7: "article4.canterbury.blean.b",
8: "article4.canterbury.bridge",
9: "article4.canterbury.brookefield",
10: "article4.canterbury.chartham",
11: "article4.canterbury.chestfield",
12: "article4.canterbury.chislet.b22",
13: "article4.canterbury.chislet.b7",
14: "article4.canterbury.city",
15: "article4.canterbury.denstroude.03A",
16: "article4.canterbury.denstroude.3",
17: "article4.canterbury.fordwich",
18: "article4.canterbury.fouracres",
19: "article4.canterbury.graveneymarshes",
20: "article4.canterbury.hackington",
21: "article4.canterbury.harbledown.b35",
22: "article4.canterbury.harbledown.b5",
23: "article4.canterbury.herne",
24: "article4.canterbury.hernebay",
25: "article4.canterbury.hoath.b17",
26: "article4.canterbury.hoath.b23",
27: "article4.canterbury.ickham.b24",
28: "article4.canterbury.ickham.b26",
29: "article4.canterbury.ickham.b8",
30: "article4.canterbury.kemberlandwood",
31: "article4.canterbury.kingston",
32: "article4.canterbury.littlebourne",
33: "article4.canterbury.lovelane",
34: "article4.canterbury.lowerhardres",
35: "article4.canterbury.mountswood",
36: "article4.canterbury.nackington",
37: "article4.canterbury.nelsonroad",
38: "article4.canterbury.patrixbourne",
39: "article4.canterbury.pennypotwoods",
40: "article4.canterbury.petham.b19",
41: "article4.canterbury.petham.b31",
42: "article4.canterbury.sanpitwood",
43: "article4.canterbury.southwhitstable",
44: "article4.canterbury.stmartinshospital.c1",
45: "article4.canterbury.stmartinshospital.c2",
46: "article4.canterbury.stodmarsh",
47: "article4.canterbury.sturry",
48: "article4.canterbury.thruxtedmarshes",
49: "article4.canterbury.tylerhill",
50: "article4.canterbury.upperharbledown",
51: "article4.canterbury.upperhardres.b38",
52: "article4.canterbury.upperhardres.b6",
53: "article4.canterbury.vikingsestate",
54: "article4.canterbury.walderchainwood.1",
55: "article4.canterbury.walderchainwood.2",
56: "article4.canterbury.waltham",
57: "article4.canterbury.watermill",
58: "article4.canterbury.westbere",
59: "article4.canterbury.whitstable.b13",
60: "article4.canterbury.whitstable.b32",
61: "article4.canterbury.whitstablebeach",
62: "article4.canterbury.whitstableconservation",
63: "article4.canterbury.womenswold.b15",
64: "article4.canterbury.womenswold.b41",
65: "article4.canterbury.yorkletts",
}
},
"article4.canterbury.hmo": {
key: "article4.canterbury.hmo",
source: canterburyDomain,
id: "External/Planning_Constraints_New",
serverIndex: 6,
fields: ["OBJECTID", "REF", "LOCATION_1", "COMMENT", "DESCRIPTIO"],
neg: "is not subject to any Article 4 Restrictions",
pos: (data) => ({
text: "is subject to Article 4 Restriction(s)",
description: data.LOCATION_1,
Expand All @@ -28,20 +108,33 @@ const planningConstraints = {
listed: {
key: "listed",
source: canterburyDomain,
id: "External/Heritage",
serverIndex: 6,
id: "External/Planning_Constraints_New",
serverIndex: 7,
fields: ["OBJECTID", "GRADE", "NAME", "DESCRIPTIO"],
neg: "is not in, or within, a Listed Building",
pos: (data) => ({
text: `is, or is within, a Listed Building Grade ${data.GRADE}`,
description: data.NAME,
}),
},
// "Locally listed buildings" do not have a grade; determine if these require more granular planx variable
"listed.local": {
key: "listed.local",
source: canterburyDomain,
id: "External/Planning_Constraints_New",
serverIndex: 8,
fields: ["OBJECTID", "LOCATION", "DESCRIPTIO", "POLICY", "info1"],
neg: "is not in, or within, a Locally Listed Building",
pos: (data) => ({
text: `is, or is within, a Locally Listed Building`,
}),
},
"designated.conservationArea": {
key: "designated.conservationArea",
source: canterburyDomain,
id: "Open_Data/Conservation_Areas",
fields: ["OBJECTID", "NAME", "URL"],
id: "External/Planning_Constraints_New",
serverIndex: 4,
fields: ["OBJECTID", "NAME", "TYPE", "DESIGNATIO", "DESCRIPTIO", "URL"],
neg: "is not in a Conservation Area",
pos: (data) => ({
text: "is in a Conservation Area",
Expand All @@ -50,9 +143,10 @@ const planningConstraints = {
},
"designated.AONB": {
key: "designated.AONB",
source: environmentDomain,
id: "NE/AreasOfOutstandingNaturalBeautyEngland",
fields: ["objectid", "code", "name", "desig_date", "hotlink"],
source: canterburyDomain,
id: "External/Planning_Constraints_New",
serverIndex: 2,
fields: ["OBJECTID", "NAME", "DESIG_DATE", "HOTLINK"],
neg: "is not an Area of Outstanding Natural Beauty",
pos: (data) => ({
text: "is, or is within, an Area of Outstanding Natural Beauty",
Expand All @@ -72,24 +166,36 @@ const planningConstraints = {
"designated.WHS": {
key: "designated.WHS",
source: canterburyDomain,
id: "External/Heritage",
serverIndex: 1,
fields: ["OBJECTID", "NAME", "NOTES"],
id: "External/Planning_Constraints_New",
serverIndex: 13,
fields: ["OBJECTID", "NAME"],
neg: "is not an UNESCO World Heritage Site",
pos: (data) => ({
text: "is an UNESCO World Heritage Site",
description: data.NAME,
}),
},
"designated.monument": { value: false },
"designated.monument": {
key: "designated.monument",
source: canterburyDomain,
id: "External/Planning_Constraints_New",
serverIndex: 0,
fields: ["OBJECTID", "NAME", "SchedDate", "AmendDate"],
neg: "is not the site of an Ancient Monument",
pos: (data) => ({
text: "is the site of an Ancient Monument",
description: data.NAME,
}),
},
tpo: {
key: "tpo",
source: canterburyDomain,
id: "Open_Data/Tree_Preservation_Orders",
fields: ["OBJECTID", "TPO"],
neg: "is not in a TPO (Tree Preservation Order) zone",
id: "External/Planning_Constraints_New",
serverIndex: 13,
fields: ["OBJECTID", "TPO", "TPO_Group", "Location", "Description"],
neg: "is not in a TPO (Tree Preservation Order) Zone",
pos: (data) => ({
text: "is in a TPO (Tree Preservation Order) zone",
text: "is in a TPO (Tree Preservation Order) Zone",
description: data,
}),
},
Expand Down
11 changes: 11 additions & 0 deletions api.planx.uk/gis/local_authorities/metadata/lambeth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ const planningConstraints = {
description: data.NAME,
}),
},
"article4.lambeth.caz": {
key: "article4.lambeth.caz",
source: lambethDomain,
id: "LambethCentralActivitiesZone",
fields: ["OBJECTID", "TITLE", "POLICY"],
neg: "is not subject to any Article 4 directions",
pos: (data) => ({
text: "is subject to an Article 4 direction(s)",
description: data.TITLE,
}),
},
listed: {
key: "listed",
source: lambethDomain,
Expand Down
8 changes: 4 additions & 4 deletions api.planx.uk/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ describe("fetching GIS data from local authorities", () => {
},
{
council: "canterbury",
x: 615806.3528948927,
y: 157824.02262987028,
x: 621192.0132463141,
y: 157770.55052344775,
},
{
council: "lambeth",
x: 531372.771064619,
y: 177420.151319974,
x: 530622.7463248332,
y: 178706.16704920324,
},
{
council: "southwark",
Expand Down
Loading

0 comments on commit 1399125

Please sign in to comment.