-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from interactivethings/mutations
Swiss municipalities mutations audit
- Loading branch information
Showing
13 changed files
with
2,543 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { GeoJsonLayer } from "@deck.gl/layers"; | ||
import DeckGL from "@deck.gl/react"; | ||
import React, { ComponentProps } from "react"; | ||
import { useGeoData } from "src/domain/geodata"; | ||
import { MapController } from "@deck.gl/core"; | ||
|
||
export const LINE_COLOR = [100, 100, 100, 127] as const; | ||
|
||
const MutationsMap = ({ | ||
highlightedMunicipalities, | ||
geoData, | ||
...props | ||
}: { | ||
highlightedMunicipalities: { | ||
added: number[]; | ||
removed: number[]; | ||
}; | ||
geoData: ReturnType<typeof useGeoData>["data"]; | ||
} & ComponentProps<typeof DeckGL>) => { | ||
return ( | ||
<DeckGL | ||
controller={MapController} | ||
getTooltip={({ | ||
object, | ||
}: { | ||
object: { properties: { name: string } }; | ||
}) => { | ||
if (!object) { | ||
return; | ||
} | ||
return "Municipality: " + object.properties.name; | ||
}} | ||
{...props} | ||
> | ||
{geoData.municipalities && ( | ||
<GeoJsonLayer | ||
id="municipalities" | ||
data={geoData.municipalities} | ||
pickable={true} | ||
stroked={true} | ||
filled={true} | ||
extruded={false} | ||
lineWidthMinPixels={0.5} | ||
lineWidthMaxPixels={1} | ||
getLineWidth={200} | ||
lineMiterLimit={1} | ||
updateTriggers={{ getFillColor: highlightedMunicipalities }} | ||
getLineColor={[30, 30, 30]} | ||
getFillColor={(d: { properties: { id: number } }) => { | ||
return highlightedMunicipalities.added.includes(d.properties.id) | ||
? [0, 255, 0, 100] | ||
: highlightedMunicipalities.removed.includes(d.properties.id) | ||
? [255, 0, 0, 100] | ||
: [255, 255, 255]; | ||
}} | ||
/> | ||
)} | ||
</DeckGL> | ||
); | ||
}; | ||
|
||
export default MutationsMap; |
Oops, something went wrong.