Skip to content

Commit

Permalink
Merge pull request #1448 from cityofaustin/md-17104-crash-coords-nan
Browse files Browse the repository at this point in the history
[BUG] Crash coordinates render as NaN when they should be blank
  • Loading branch information
mddilley authored May 16, 2024
2 parents a0a09d3 + 6c4dce4 commit 02bf086
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
13 changes: 8 additions & 5 deletions atd-vze/src/views/Crashes/Crash.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function Crash(props) {
data &&
data?.atd_txdot_crashes.length > 0 &&
data?.atd_txdot_crashes[0]["location_id"];
const notEditingCoords = !isEditingCoords && latitude && longitude;
const hasCoordinates = !!latitude && !!longitude;

return !data?.atd_txdot_crashes?.length ? (
<Page404 />
Expand Down Expand Up @@ -237,7 +237,7 @@ function Crash(props) {
)
<br />
Geocode Provider:{" "}
{latitude && longitude
{hasCoordinates
? geocodeMethod.name
: "No Primary Coordinates"}
</Col>
Expand All @@ -254,14 +254,17 @@ function Crash(props) {
</Col>
</Row>
</CardHeader>
<CardBody style={{ minHeight: "350px" }}>
{(!latitude || !longitude) && (
<CardBody
className="d-flex flex-column"
style={{ minHeight: "400px" }}
>
{!hasCoordinates && (
<Alert color="danger">
Crash record is missing latitude and longitude values required
for map display.
</Alert>
)}
{notEditingCoords ? (
{!isEditingCoords ? (
<CrashMap data={data.atd_txdot_crashes[0]} />
) : (
<CrashEditCoordsMap
Expand Down
9 changes: 7 additions & 2 deletions atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const CrashEditCoordsMap = ({
// Reset marker to original coordinates or default fallback
const originalMarkerCoordinates = {
latitude: latitude_primary || defaultInitialState.latitude,
longitude: longitude_primary || defaultInitialState.latitude,
longitude: longitude_primary || defaultInitialState.longitude,
};

// Move map center and marks to original coordinates or default fallback
Expand Down Expand Up @@ -108,7 +108,12 @@ const CrashEditCoordsMap = ({
>
<FullscreenControl position="top-left" />
<NavigationControl position="top-left" showCompass={false} />
<Marker {...markerCoordinates}>
<Marker
latitude={markerCoordinates.latitude || defaultInitialState.latitude}
longitude={
markerCoordinates.longitude || defaultInitialState.longitude
}
>
<Pin size={40} color={"warning"} isDragging={isDragging} animated />
</Marker>
{/* add nearmap raster source and style */}
Expand Down
4 changes: 2 additions & 2 deletions atd-vze/src/views/Crashes/Maps/CrashEditLatLonForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const CrashEditLatLonForm = ({
id="qa-latitude"
name="qa-latitude"
placeholder=""
value={truncateCoordinate(latitude)}
value={!!latitude ? truncateCoordinate(latitude) : "None"}
readOnly
/>
</Col>
Expand All @@ -36,7 +36,7 @@ export const CrashEditLatLonForm = ({
id="qa-longitude"
name="qa-longitude"
placeholder=""
value={truncateCoordinate(longitude)}
value={!!longitude ? truncateCoordinate(longitude) : "None"}
readOnly
/>
</Col>
Expand Down

0 comments on commit 02bf086

Please sign in to comment.