Skip to content

Commit

Permalink
PSP-7819 FT: Disposition File - Grey marker appears as Other Interest…
Browse files Browse the repository at this point in the history
… when the Advanced Filters for IS_DISPOSED is not selected (#3793)

* Update typing of map layer

* Update map machine state when closing advanced filter

* Fix map pin rendering logic to accommodate DISPOSED properties

* Test corrections
  • Loading branch information
asanchezr authored Feb 15, 2024
1 parent d19fa00 commit 8fe93eb
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const featureViewStates = {
on: {
TOGGLE_FILTER: {
target: 'browsing',
actions: assign({ showDisposed: () => false }),
},
TOGGLE_LAYERS: {
target: 'layerControl',
Expand Down
233 changes: 147 additions & 86 deletions source/frontend/src/components/maps/leaflet/Layers/util.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import { ICluster } from '../../types';
import {
createClusterMarker,
createPoints,
disposedIcon,
getMarkerIcon,
otherInterestIcon,
otherInterestIconSelect,
parcelIcon,
pointToLayer,
propertyOfInterestIcon,
} from './util';
describe('mapUtils tests', () => {
describe('pointToLayer function', () => {
Expand All @@ -34,7 +36,7 @@ describe('mapUtils tests', () => {
type: 'Point',
coordinates: [1, 2],
},
properties: { ...EmptyPropertyLocation, PROPERTY_ID: '1' },
properties: { ...EmptyPropertyLocation, PROPERTY_ID: '1', IS_OTHER_INTEREST: true },
};
const latlng: LatLngExpression = { lat: 1, lng: 2 };

Expand Down Expand Up @@ -68,6 +70,7 @@ describe('mapUtils tests', () => {
expect(pointToLayer(feature, latlng)).toEqual(new Marker(latlng, { icon }));
});
});

describe('createClusterMarker function', () => {
it('returns null when passed a feature that is not a cluster', () => {
const feature: ICluster = {
Expand All @@ -83,7 +86,8 @@ describe('mapUtils tests', () => {
expect(createClusterMarker(feature, latlng)).toBeNull();
});
});
describe('getMarkericon function', () => {

describe('getMarkerIcon function', () => {
const feature: ICluster = {
id: 1,
type: 'Feature',
Expand All @@ -96,106 +100,163 @@ describe('mapUtils tests', () => {
point_count_abbreviated: 100,
},
};
it('returns a default parcel icon', () => {
it(`returns a valid map pin icon for 'Core Inventory'`, () => {
expect(
getMarkerIcon(
{
...feature,
properties: { ...EmptyPropertyLocation, PROPERTY_ID: '1' },
properties: { ...EmptyPropertyLocation, PROPERTY_ID: '1', IS_OWNED: true },
},
true,
false,
),
).toEqual(otherInterestIconSelect);
).toEqual(parcelIcon);
});

describe('create points function', () => {
const property: IProperty = {
id: 1,
pid: '000-000-001',
statusId: PropertyStatusTypes.UnderAdmin,
classificationId: PropertyClassificationTypes.CoreOperational,
tenureId: PropertyTenureTypes.HighwayRoad,
dataSourceId: PropertyDataSourceTypes.PAIMS,
dataSourceEffectiveDate: '2021-08-30T18:11:13.883Z',
address: {
streetAddress1: '1243 St',
provinceId: 1,
municipality: '',
postal: '',
},
regionId: 1,
districtId: 1,
areaUnitId: PropertyAreaUnitTypes.Hectare,
landArea: 0,
landLegalDescription: '',
latitude: 1,
longitude: 2,
isSensitive: false,
};
it('converts properties to point features', () => {
expect(createPoints([property, property])).toEqual([
it(`returns a valid map pin icon for 'Property of Interest'`, () => {
expect(
getMarkerIcon(
{
geometry: { coordinates: [2, 1], type: 'Point' },
...feature,
properties: {
PROPERTY_ID: 1,
address: {
streetAddress1: '1243 St',
provinceId: 1,
municipality: '',
postal: '',
},
areaUnitId: PropertyAreaUnitTypes.Hectare,
classificationId: PropertyClassificationTypes.CoreOperational,
dataSourceId: PropertyDataSourceTypes.PAIMS,
dataSourceEffectiveDate: property.dataSourceEffectiveDate,
districtId: 1,
cluster: false,
id: 1,
isSensitive: false,
latitude: 1,
longitude: 2,
tenureId: PropertyTenureTypes.HighwayRoad,
statusId: PropertyStatusTypes.UnderAdmin,
regionId: 1,
landArea: 0,
landLegalDescription: '',
pid: '000-000-001',
...EmptyPropertyLocation,
PROPERTY_ID: '1',
IS_PROPERTY_OF_INTEREST: true,
},
type: 'Feature',
},
false,
),
).toEqual(propertyOfInterestIcon);
});
it(`returns a valid map pin icon for 'Other Interest'`, () => {
expect(
getMarkerIcon(
{
...feature,
properties: { ...EmptyPropertyLocation, PROPERTY_ID: '1', IS_OTHER_INTEREST: true },
},
false,
),
).toEqual(otherInterestIcon);
});
it(`returns a valid map pin icon for 'Disposed'`, () => {
expect(
getMarkerIcon(
{
...feature,
properties: { ...EmptyPropertyLocation, PROPERTY_ID: '1', IS_DISPOSED: true },
},
false,
true,
),
).toEqual(disposedIcon);
});
it(`returns null when passed feature is not one of: 'Core Inventory', 'Property of Interest', 'Other Interest' or 'Disposed'`, () => {
expect(
getMarkerIcon(
{
geometry: { coordinates: [2, 1], type: 'Point' },
...feature,
properties: {
PROPERTY_ID: 1,
address: {
streetAddress1: '1243 St',
provinceId: 1,
municipality: '',
postal: '',
},
areaUnitId: PropertyAreaUnitTypes.Hectare,
classificationId: PropertyClassificationTypes.CoreOperational,
dataSourceId: PropertyDataSourceTypes.PAIMS,
dataSourceEffectiveDate: property.dataSourceEffectiveDate,
districtId: 1,
cluster: false,
id: 1,
isSensitive: false,
latitude: 1,
longitude: 2,
tenureId: PropertyTenureTypes.HighwayRoad,
statusId: PropertyStatusTypes.UnderAdmin,
regionId: 1,
landArea: 0,
landLegalDescription: '',
pid: '000-000-001',
...EmptyPropertyLocation,
PROPERTY_ID: '1',
IS_OWNED: null,
IS_PROPERTY_OF_INTEREST: null,
IS_OTHER_INTEREST: null,
IS_DISPOSED: null,
},
type: 'Feature',
},
]);
});
true,
),
).toBeNull();
});
});

describe('create points function', () => {
const property: IProperty = {
id: 1,
pid: '000-000-001',
statusId: PropertyStatusTypes.UnderAdmin,
classificationId: PropertyClassificationTypes.CoreOperational,
tenureId: PropertyTenureTypes.HighwayRoad,
dataSourceId: PropertyDataSourceTypes.PAIMS,
dataSourceEffectiveDate: '2021-08-30T18:11:13.883Z',
address: {
streetAddress1: '1243 St',
provinceId: 1,
municipality: '',
postal: '',
},
regionId: 1,
districtId: 1,
areaUnitId: PropertyAreaUnitTypes.Hectare,
landArea: 0,
landLegalDescription: '',
latitude: 1,
longitude: 2,
isSensitive: false,
};
it('converts properties to point features', () => {
expect(createPoints([property, property])).toEqual([
{
geometry: { coordinates: [2, 1], type: 'Point' },
properties: {
PROPERTY_ID: 1,
address: {
streetAddress1: '1243 St',
provinceId: 1,
municipality: '',
postal: '',
},
areaUnitId: PropertyAreaUnitTypes.Hectare,
classificationId: PropertyClassificationTypes.CoreOperational,
dataSourceId: PropertyDataSourceTypes.PAIMS,
dataSourceEffectiveDate: property.dataSourceEffectiveDate,
districtId: 1,
cluster: false,
id: 1,
isSensitive: false,
latitude: 1,
longitude: 2,
tenureId: PropertyTenureTypes.HighwayRoad,
statusId: PropertyStatusTypes.UnderAdmin,
regionId: 1,
landArea: 0,
landLegalDescription: '',
pid: '000-000-001',
},
type: 'Feature',
},
{
geometry: { coordinates: [2, 1], type: 'Point' },
properties: {
PROPERTY_ID: 1,
address: {
streetAddress1: '1243 St',
provinceId: 1,
municipality: '',
postal: '',
},
areaUnitId: PropertyAreaUnitTypes.Hectare,
classificationId: PropertyClassificationTypes.CoreOperational,
dataSourceId: PropertyDataSourceTypes.PAIMS,
dataSourceEffectiveDate: property.dataSourceEffectiveDate,
districtId: 1,
cluster: false,
id: 1,
isSensitive: false,
latitude: 1,
longitude: 2,
tenureId: PropertyTenureTypes.HighwayRoad,
statusId: PropertyStatusTypes.UnderAdmin,
regionId: 1,
landArea: 0,
landLegalDescription: '',
pid: '000-000-001',
},
type: 'Feature',
},
]);
});
});

describe('toCqlFilter function', () => {
it('by default, joins multiple filters with and and inserts ilike', () => {
const cql = toCqlFilterValue({ PID: '12345678', PIN: '54321' });
Expand Down
22 changes: 13 additions & 9 deletions source/frontend/src/components/maps/leaflet/Layers/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,35 +178,39 @@ export function getMarkerIcon(
feature: Supercluster.PointFeature<PIMS_Property_Location_View | PIMS_Property_Boundary_View>,
selected: boolean,
showDisposed: boolean = false,
): L.Icon<L.IconOptions> {
if (showDisposed && feature.properties.IS_DISPOSED) {
): L.Icon<L.IconOptions> | null {
if (showDisposed && feature?.properties?.IS_DISPOSED === true) {
if (selected) {
return disposedIconSelect;
} else {
return disposedIcon;
}
}

if (feature.properties.IS_PROPERTY_OF_INTEREST) {
if (feature?.properties?.IS_PROPERTY_OF_INTEREST === true) {
if (selected) {
return propertyOfInterestIconSelect;
} else {
return propertyOfInterestIcon;
}
}

if (feature.properties.IS_OWNED) {
if (feature?.properties?.IS_OWNED === true) {
if (selected) {
return parcelIconSelect;
}
return parcelIcon;
}

if (selected) {
return otherInterestIconSelect;
} else {
return otherInterestIcon;
if (feature?.properties?.IS_OTHER_INTEREST === true) {
if (selected) {
return otherInterestIconSelect;
} else {
return otherInterestIcon;
}
}

return null;
}

/**
Expand Down Expand Up @@ -243,7 +247,7 @@ export const createSingleMarker = <P extends MarkerFeature>(

if (isOwned) {
const icon = getMarkerIcon(feature, false);
return new Marker(latlng, { icon });
return icon ? new Marker(latlng, { icon }) : (null as unknown as Layer);
} else {
const icon = getNotOwnerMarkerIcon(false);
return new Marker(latlng, { icon });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ const SinglePropertyMarker: React.FC<React.PropsWithChildren<SinglePropertyMarke
}) => {
const mapMachine = useMapStateMachine();

const isOwned = isPimsFeature(pointFeature);

const getIcon = () => {
const getIcon = (
feature: PointFeature<
PIMS_Property_Location_View | PIMS_Property_Boundary_View | PMBC_Feature_Properties
>,
isSelected: boolean,
showDisposed: boolean,
): L.Icon<L.IconOptions> | null => {
const isOwned = isPimsFeature(feature);
if (isOwned) {
return getMarkerIcon(pointFeature, isSelected, mapMachine.showDisposed);
return getMarkerIcon(feature, isSelected, showDisposed);
} else {
return getNotOwnerMarkerIcon(isSelected);
}
Expand Down Expand Up @@ -75,19 +80,21 @@ const SinglePropertyMarker: React.FC<React.PropsWithChildren<SinglePropertyMarke
}
};

return (
// render single marker, not in a cluster
const icon = getIcon(pointFeature, isSelected, mapMachine.showDisposed);

// render single marker, not in a cluster
return icon ? (
<Marker
{...pointFeature.properties}
position={markerPosition}
icon={getIcon()}
icon={icon}
eventHandlers={{
click: e => {
onMarkerClicked();
},
}}
/>
);
) : null;
};

export default SinglePropertyMarker;
Loading

0 comments on commit 8fe93eb

Please sign in to comment.