ImpactMap
Overview
ImpactMap
is a React component that visualizes the potential effects of an asteroid impact on a geographic area using Leaflet maps. It integrates multiple layers of information, including impact zones, population heatmaps, and historical earthquakes, and provides interactive tooltips and panels for detailed information.
State Management
impact: Stores data about the asteroid impact, including position, energy, class, size, and impact zones. Initialized via dummy data.
cities: Stores the list of cities fetched from an API within the maximum impact radius.
zonesPopulation: Maps each impact zone to the total population affected.
earthquakes: Stores historical earthquake data similar in magnitude and proximity to the impact.
isPanelOpen: Boolean controlling the visibility of the sliding earthquake info panel.
selectedEq: Stores the currently selected earthquake for detailed view.
Utilities
haversineDistance Calculates the great-circle distance between two latitude/longitude points on the Earth’s surface using the Haversine formula.
findCitiesWithinRadius Filters a list of cities to those within a given radius from a specified latitude and longitude.
calculateImpactMagnitude Converts an impact energy in megatons to an estimated earthquake magnitude using an empirical formula.
fetchSimilarEarthquakes Fetches historical earthquakes from the USGS API within 500 km of the impact point and within ±0.5 magnitude of the calculated impact magnitude.
generateDummyImpactData Produces a mock asteroid impact dataset, including latitude, longitude, size, class, energy, and multiple impact zones with radii and effects.
Map and Layers
MapContainer
Provides the base Leaflet map.
Centered at the impact latitude and longitude.
Zoom level set to 6.
Occupies the full viewport height and width.
TileLayer
Uses OpenStreetMap tiles for the map base layer.
Impact Marker
A
Marker
at the asteroid impact location.Includes a permanent
Tooltip
displaying the asteroid information (ID, name, size, class, energy, global effects, atmospheric entry).
Impact Zones
Rendered as
Circle
layers for each zone in the impact data.Radius is scaled in meters (
radius * 1000
).Each circle has a unique color and opacity to indicate severity.
Tooltips show zone-specific information: radius, effect, and population affected.
Population Heatmap
Uses a custom
HeatmapLayer
component that integrates Leaflet's heatmap plugin.Points are scaled by log of city population for visual clarity.
Provides a heatmap overlay representing population density around the impact.
Historical Earthquake Markers
Displays markers for earthquakes similar in magnitude to the impact.
Each marker has a permanent tooltip with magnitude, location, and date.
Selected earthquakes can be expanded to show detailed information in the sliding panel.
Info Panels
Meteor Info Panel
Displays detailed information about the asteroid.
Rendered as a styled overlay inside the tooltip of the impact marker.
Zone Info Panels
Show radius, description, and estimated population affected for each impact zone.
City Info Panels
Display population and coordinates for individual cities (used in heatmap or future enhancements).
Sliding Earthquake Panel
Fixed-position panel that lists historical earthquakes.
Can be opened/closed with buttons.
Each list item provides basic information and a "More Info" button.
Expanded earthquake details include place, magnitude, date, and coordinates.
Data Fetching and Effects
On component mount, dummy asteroid data is generated and stored in state.
When
impact
is set:Fetches nearby cities from an API endpoint.
Calculates cumulative population affected for each impact zone.
Calculates estimated earthquake magnitude from impact energy.
Fetches historical earthquakes similar in magnitude and proximity.
Updates state asynchronously for cities, zonesPopulation, and earthquakes.
Interaction and UX
Tooltips: Provide detailed, styled information for impact marker, zones, and earthquakes.
Heatmap: Visually indicates population concentration.
Sliding Panel: Allows users to explore historical earthquakes related to impact magnitude.
Buttons: Toggle visibility of the earthquake panel and show detailed earthquake information.
Layer Order: Impact zones are rendered in reverse order for correct layering of tooltips and pointer interactions.
Visualization Logic
Impact Zones: Inner zones overlayed with higher opacity; outer zones semi-transparent.
Population Heatmap: Intensity proportional to log of city population to prevent skew from large cities.
Earthquake Filtering: Only displays earthquakes within 500 km and ±0.5 magnitude of impact-equivalent magnitude.
Markers: Default Leaflet markers are customized for impact and historical earthquakes.
Summary
ImpactMap
is a comprehensive geospatial visualization tool for asteroid impacts. It combines:
Realistic impact zones with population analysis.
Interactive map and tooltips for immediate information.
Historical earthquake comparison using USGS data.
Population heatmaps to show potential human impact.
Sliding panels and detailed modals for interactive exploration.
The component is fully reactive to updates in asteroid data and dynamically fetches supplementary information, making it suitable for simulation and risk assessment scenarios.
Last updated