Skip to content

Commit

Permalink
Filter projects by ccd and highlight district
Browse files Browse the repository at this point in the history
Add tiles filtering and district highlighting for ccd

Use hasDistrict boolean in both layers

Format

Use empty array instead of empty string
  • Loading branch information
pratishta committed Aug 14, 2024
1 parent 0a25662 commit 5923db5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/components/atlas.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
useCommunityDistrictsLayer,
useCityCouncilDistrictsLayer,
useCommunityDistrictLayer,
useCityCouncilDistrictLayer,
} from "./layers";
import type { MapView, MapViewState } from "@deck.gl/core";

Expand All @@ -29,6 +30,7 @@ export function Atlas() {
const communityDistrictsLayer = useCommunityDistrictsLayer();
const communityDistrictLayer = useCommunityDistrictLayer();
const cityCouncilDistrictsLayer = useCityCouncilDistrictsLayer();
const cityCouncilDistrictLayer = useCityCouncilDistrictLayer();

const isMobile = useMediaQuery("(max-width: 767px)")[0];
const widgetPlacement = isMobile ? "top-right" : "bottom-right";
Expand Down Expand Up @@ -71,6 +73,7 @@ export function Atlas() {
communityDistrictsLayer,
communityDistrictLayer,
cityCouncilDistrictsLayer,
cityCouncilDistrictLayer,
]}
getCursor={({ isDragging, isHovering }) => {
if (isDragging) {
Expand Down
1 change: 1 addition & 0 deletions app/components/layers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { useCapitalProjectsLayer } from "./useCapitalProjectsLayer.client";
export { useCommunityDistrictsLayer } from "./useCommunityDistrictsLayer.client";
export { useCommunityDistrictLayer } from "./useCommunityDistrictLayer.client";
export { useCityCouncilDistrictsLayer } from "./useCityCouncilDistrictsLayer.client";
export { useCityCouncilDistrictLayer } from "./useCityCouncilDistrictLayer.client";
17 changes: 14 additions & 3 deletions app/components/layers/useCapitalProjectsLayer.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ export interface CapitalProjectProperties {
managingAgency: string;
}
export function useCapitalProjectsLayer() {
const { managingCode, capitalProjectId, boroughId, communityDistrictId } =
useParams();
const {
managingCode,
capitalProjectId,
boroughId,
communityDistrictId,
cityCouncilDistrictId,
} = useParams();
const [searchParams] = useSearchParams();
const navigate = useNavigate();
const hasCityCouncilDistrict = cityCouncilDistrictId !== undefined;
const hasCommunityDistrict =
boroughId !== undefined && communityDistrictId !== undefined;

let endpointPrefix = "";
if (boroughId !== undefined && communityDistrictId !== undefined)
if (hasCityCouncilDistrict) {
endpointPrefix = `city-council-districts/${cityCouncilDistrictId}/`;
} else if (hasCommunityDistrict) {
endpointPrefix = `boroughs/${boroughId}/community-districts/${communityDistrictId}/`;
}

return new MVTLayer<CapitalProjectProperties>({
id: "capitalProjects",
Expand Down
21 changes: 21 additions & 0 deletions app/components/layers/useCityCouncilDistrictLayer.client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { GeoJsonLayer } from "@deck.gl/layers";
import { useParams } from "@remix-run/react";

export function useCityCouncilDistrictLayer() {
const { cityCouncilDistrictId } = useParams();
const hasCityCouncilDistrict = cityCouncilDistrictId !== undefined;
const data = hasCityCouncilDistrict
? `${import.meta.env.VITE_ZONING_API_URL}/api/city-council-districts/${cityCouncilDistrictId}/geojson`
: [];

return new GeoJsonLayer({
id: "CityCouncilDistrict",
data,
visible: hasCityCouncilDistrict,
filled: false,
stroked: true,
lineWidthUnits: "pixels",
getLineWidth: 3,
getLineColor: [49, 151, 149],
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function CapitalProjectsByCityCouncilDistrictId() {
return <></>;
}

0 comments on commit 5923db5

Please sign in to comment.