Skip to content

Commit

Permalink
CE-199-Refactoring of edit and geocoding functionality (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrfalk authored Oct 30, 2023
1 parent 42a6f6c commit 50ae17a
Show file tree
Hide file tree
Showing 7 changed files with 507 additions and 468 deletions.
8 changes: 4 additions & 4 deletions backend/src/external_api/bc_geo_coder/bc_geo_coder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class BcGeoCoderService {

// given a localityName (community, for example) and an address, return the Feature given by BC Geocoder
async findAll(localityName: string, addressString: string): Promise<Feature> {
const maxResults = 10;
const maxResults = 1; // will need to update this for the purposes of autocomplete.
let apiUrl: string;
this.logger.debug(
`Calling BC Geocoder. Parameters sent to backend were localityName: ${localityName} and addressString: ${addressString}`
Expand All @@ -21,13 +21,13 @@ export class BcGeoCoderService {
this.logger.debug(
`Calling BC Geocoder with address ${addressString} and community ${localityName}`
);
apiUrl = `${process.env.BC_GEOCODER_API_URL}/addresses.json?addressString=${addressString}&locationDescriptor=any&maxResults=${maxResults}&interpolation=adaptive&echo=true&brief=false&autoComplete=true&setBack=0&outputSRS=4326&minScore=2&localityName=${localityName}&provinceCode=BC`;
apiUrl = `${process.env.BC_GEOCODER_API_URL}/addresses.json?addressString=${addressString}&locationDescriptor=any&maxResults=${maxResults}&interpolation=adaptive&echo=true&brief=false&autoComplete=true&setBack=0&outputSRS=4326&minScore=1&localityName=${localityName}&provinceCode=BC`;
} else if (localityName) {
this.logger.debug(`Calling BC Geocoder with community ${localityName}`);
apiUrl = `${process.env.BC_GEOCODER_API_URL}/addresses.json?locationDescriptor=any&maxResults=${maxResults}&interpolation=adaptive&echo=true&brief=false&autoComplete=true&setBack=0&outputSRS=4326&minScore=2&localityName=${localityName}&provinceCode=BC`;
apiUrl = `${process.env.BC_GEOCODER_API_URL}/addresses.json?locationDescriptor=any&maxResults=${maxResults}&interpolation=adaptive&echo=true&brief=false&autoComplete=false&setBack=0&outputSRS=4326&minScore=1&localityName=${localityName}&provinceCode=BC`;
} else if (addressString && addressString.length > 0) {
this.logger.debug(`Calling BC Geocoder with address ${addressString}`);
apiUrl = `${process.env.BC_GEOCODER_API_URL}/addresses.json?addressString=${addressString}&locationDescriptor=any&maxResults=${maxResults}&interpolation=adaptive&echo=true&brief=false&autoComplete=true&setBack=0&outputSRS=4326&minScore=2&provinceCode=BC`;
apiUrl = `${process.env.BC_GEOCODER_API_URL}/addresses.json?addressString=${addressString}&locationDescriptor=any&maxResults=${maxResults}&interpolation=adaptive&echo=true&brief=false&autoComplete=true&setBack=0&outputSRS=4326&minScore=1&provinceCode=BC`;
}
if (apiUrl) {
const apiKey = process.env.BC_GEOCODER_API_URL;
Expand Down
8 changes: 1 addition & 7 deletions frontend/cypress/e2e/allegation-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ describe("COMPENF-37 Display ECR Details", () => {
cy.get('span[id="comp-details-region"]').contains(callDetails.region);
});

it("it has a map on screen with a marker at the correct location", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-006888");
cy.verifyMapMarkerExists(true);
cy.get(".comp-complaint-details-alert").should("not.exist");
});

it("it has a map on screen with no marker", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-032528");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-032528");
cy.verifyMapMarkerExists(false);
cy.get(".comp-complaint-details-alert").should("exist");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CreatableSelect from "react-select/creatable";
import { useAppDispatch, useAppSelector } from "../../hooks/hooks";
import {
getComplaintLocationByAddress,
selectComplaintLocation,
selectGeocodedComplaintCoordinates,
} from "../../store/reducers/complaints";

interface Props {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const BCGeocoderAutocomplete: FC<Props> = ({
};

const dispatch = useAppDispatch();
const complaintLocation = useAppSelector(selectComplaintLocation);
const complaintLocation = useAppSelector(selectGeocodedComplaintCoordinates);

useEffect(() => {
const fetchAddresses = async (inputValue: string) => {
Expand Down
Loading

0 comments on commit 50ae17a

Please sign in to comment.