Skip to content

Commit

Permalink
update map service and filters
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiaifrim committed Sep 21, 2020
1 parent ad1ddca commit 3291c69
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ const OpenlayersMapView = (props) => {
sitesSource = new VectorSource({
loader: function (extent, resolution, projection) {
if (mounted.current && firstFilteringDone.current) {
var url = `https://services.arcgis.com/LcQjj2sL7Txk9Lag/arcgis/rest/services/SiteMap_v2/FeatureServer/0/query/?f=json&returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometry=${encodeURIComponent(
var url = `https://services.arcgis.com/LcQjj2sL7Txk9Lag/arcgis/rest/services/SiteMap/FeatureServer/0/query/?f=json&returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometry=${encodeURIComponent(
'{"xmin":' +
extent[0] +
',"ymin":' +
Expand Down Expand Up @@ -802,6 +802,23 @@ const OpenlayersMapView = (props) => {
),
});
}

const siteStyle = new Style({
image: new CircleStyle({
radius: 3,
fill: new Fill({ color: '#000' }),
stroke: new Stroke({ color: '#6A6A6A', width: 1 }),
zIndex: 0,
}),
});
let selectedSite = null;

// function resetSelectedSite() {
// if (selectedSite) {
// selectedSite.setStyle(siteStyle);
// }
// }

/* ======== SOURCE LAYERS ======== */
// Sites source layer
sitesSourceLayer = new VectorLayer({
Expand Down
87 changes: 42 additions & 45 deletions src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const View = ({ content, ...props }) => {
'industries',
'countries',
'regions',
'provinces',
'river_basins',
'town_village',
'pollutant_groups',
'pollutants',
'reporting_years',
Expand Down Expand Up @@ -420,16 +420,7 @@ const View = ({ content, ...props }) => {
return "'" + country + "'";
})}) AND LEVL_CODE = 1
ORDER BY NUTS_NAME`,
// RIVER BASIN DISTRICT QUERY
siteCountryFilters &&
siteCountryFilters.length > 0 &&
`SELECT DISTINCT thematicIdIdentifier, nameText
FROM [IED].[latest].[refRBD_NoGeo]
WHERE countryCode IN (${siteCountryFilters.map((country) => {
return "'" + country + "'";
})})
ORDER BY nameText`,
// TOWN/VILLAGE QUERY
// PROVINCES QUERY
siteCountryFilters &&
regionFilters &&
siteCountryFilters.length > 0 &&
Expand All @@ -440,12 +431,19 @@ const View = ({ content, ...props }) => {
return "'" + country + "'";
})}) AND (${regionFilters
.map((region, index) => {
return (
(!index ? '' : 'OR ') + "NUTS_ID LIKE '" + region + "1%'"
);
return (!index ? '' : 'OR ') + "NUTS_ID LIKE '" + region + "%'";
})
.join(' ')}) AND LEVL_CODE = 3
.join(' ')}) AND LEVL_CODE = 2
ORDER BY NUTS_NAME`,
// RIVER BASIN DISTRICT QUERY
siteCountryFilters &&
siteCountryFilters.length > 0 &&
`SELECT DISTINCT thematicIdIdentifier, nameText
FROM [IED].[latest].[refRBD_NoGeo]
WHERE countryCode IN (${siteCountryFilters.map((country) => {
return "'" + country + "'";
})})
ORDER BY nameText`,
// POLLUTANTS QUERY
pollutantGroupFilter &&
pollutantGroupFilter.length > 0 &&
Expand Down Expand Up @@ -487,39 +485,39 @@ const View = ({ content, ...props }) => {
optionValue: 'NUTS_ID',
optionText: 'NUTS_NAME',
},
// RIVER BASIN DISTRICT META
// PROVINCES META
siteCountryFilters &&
siteCountryFilters.length > 0 && {
key: 'river_basins',
regionFilters &&
siteCountryFilters.length > 0 &&
regionFilters.length && {
key: 'provinces',
title: null,
queryToSet: 'riverBasin',
queryToSet: 'province',
firstInput: {
id: _uniqueId('select_'),
type: 'select',
position: 0,
},
placeholder: 'Select river basin district',
optionKey: 'thematicIdIdentifier',
optionValue: 'thematicIdIdentifier',
optionText: 'nameText',
placeholder: 'Select province',
optionKey: 'NUTS_ID',
optionValue: 'NUTS_ID',
optionText: 'NUTS_NAME',
},
// TOWN/VILLAGE META
// RIVER BASIN DISTRICT META
siteCountryFilters &&
regionFilters &&
siteCountryFilters.length > 0 &&
regionFilters.length && {
key: 'town_village',
siteCountryFilters.length > 0 && {
key: 'river_basins',
title: null,
queryToSet: 'townVillage',
queryToSet: 'riverBasin',
firstInput: {
id: _uniqueId('select_'),
type: 'select',
position: 0,
},
placeholder: 'Select town/village',
optionKey: 'NUTS_ID',
optionValue: 'NUTS_ID',
optionText: 'NUTS_NAME',
placeholder: 'Select river basin district',
optionKey: 'thematicIdIdentifier',
optionValue: 'thematicIdIdentifier',
optionText: 'nameText',
},
// POLLUTANTS META
pollutantGroupFilter &&
Expand Down Expand Up @@ -576,7 +574,6 @@ const View = ({ content, ...props }) => {
];
}
if (metadata[index]?.key === 'permit_years') {
// YEAH...FU*K TRACASA
filtersMeta['permit_types'] = {
filteringInputs: [
{
Expand Down Expand Up @@ -664,7 +661,7 @@ const View = ({ content, ...props }) => {
state.filters?.EEAActivity && JSON.stringify(state.filters.EEAActivity),
state.filters?.siteCountry && JSON.stringify(state.filters.siteCountry),
state.filters?.region && JSON.stringify(state.filters.region),
state.filters?.townVillage && JSON.stringify(state.filters.townVillage),
state.filters?.province && JSON.stringify(state.filters.province),
state.filters?.pollutantGroup &&
JSON.stringify(state.filters.pollutantGroup),
]);
Expand Down Expand Up @@ -737,8 +734,8 @@ const View = ({ content, ...props }) => {
let newFiltersMeta = { ...state.filtersMeta };
const dynamicFiltersQuery = [
'region',
'province',
'riverBasin',
'townVillage',
'pollutant',
];
if (state.filters && state.filtersMeta) {
Expand Down Expand Up @@ -871,7 +868,7 @@ const View = ({ content, ...props }) => {
let promises = [];
const sqls = [
{
query: `SELECT DISTINCT site FROM [IED].[latest].[Browse3_4_infotable] WHERE [site] LIKE '%${data.value}%' ORDER BY [site]`,
query: `SELECT DISTINCT siteName FROM [IED].[latest].[SiteMap] WHERE [site] LIKE '%${data.value}%' ORDER BY [siteName]`,
reqKey: 'results',
searchKey: 'site',
updateState: setSitesResults,
Expand Down Expand Up @@ -947,7 +944,7 @@ const View = ({ content, ...props }) => {
searchTermType === 'siteTerm' ? 'locationTerm' : 'siteTerm';
const siteCountries = state.filters.siteCountry;
const regions = state.filters.region;
const townVillages = state.filters.townVillage;
const provinces = state.filters.province;
let nuts = [];
let nuts_latest = [];
siteCountries &&
Expand All @@ -959,15 +956,15 @@ const View = ({ content, ...props }) => {
: [];
if (filteredRegions.length) {
filteredRegions.forEach((region) => {
const filteredTowns = townVillages
? townVillages.filter((town) => {
return town && town.includes(region);
const filteredProvinces = provinces
? provinces.filter((province) => {
return province && province.includes(region);
})
: [];
if (filteredTowns.length) {
filteredTowns.forEach((town) => {
nuts.push(`${town},${region},${country}`);
nuts_latest.push(town);
if (filteredProvinces.length) {
filteredProvinces.forEach((province) => {
nuts.push(`${province},${region},${country}`);
nuts_latest.push(province);
});
} else {
nuts.push(`${region},${country}`);
Expand Down

0 comments on commit 3291c69

Please sign in to comment.