Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
450 changes: 450 additions & 0 deletions Pinned_Locations.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# codeCollab
Binary file added __pycache__/cara.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/maps.cpython-312.pyc
Binary file not shown.
63 changes: 63 additions & 0 deletions distance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import pandas as pd
import math
import maps

# Function to calculate distance between two points using Haversine formula
def haversine(lat1, lon1, lat2, lon2):
R = 6371.0 # Radius of the Earth in kilometers

lat1_rad = math.radians(lat1)
lon1_rad = math.radians(lon1)
lat2_rad = math.radians(lat2)
lon2_rad = math.radians(lon2)

dlon = lon2_rad - lon1_rad
dlat = lat2_rad - lat1_rad

a = math.sin(dlat / 2)**2 + math.cos(lat1_rad) * math.cos(lat2_rad) * math.sin(dlon / 2)**2
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))

distance = R * c
return distance

def getShortestDist(vLat,vLong):
victim_lat = vLat
victim_lon = vLong

# Load police stations data from CSV
police_stations = pd.read_csv("police_stations.csv") # Update with your CSV filename
police_locations = {}
# Calculate distances between victim and police stations
police_stations['distance'] = police_stations.apply(
lambda row: haversine(victim_lat, victim_lon, row['latitude'], row['longitude']),
axis=1
)

# Sort police stations by distance
sorted_police_stations = police_stations.sort_values(by='distance')

# Create list of dictionaries containing name, latitude, longitude, and distance
nearest_police_stations_list = []
for _, row in sorted_police_stations.iterrows():
police_station = { #also mention phone number
'name': row['name'],
'latitude': row['latitude'],
'longitude': row['longitude'],
'distance': row['distance']
}
nearest_police_stations_list.append(police_station)

print("Nearest Police Stations:")
for police_station in nearest_police_stations_list:
print(f"{police_station['name']}: {police_station['distance']:.2f} km")

return victim_lat, victim_lon, nearest_police_stations_list

if __name__=="__main__":
vlan,vlon,npsl = getShortestDist(17.3,78.5) #current victim location --> dynamic
#dict = {ps1 : [lon, lat]}
dic = {}
for i in npsl:
dic[i['name']]=[i['latitude'],i['longitude']]
maps.show_map(17.3,78.5,dic)
#include call for twilio
27 changes: 27 additions & 0 deletions maps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import folium
import webbrowser
import os

def pin_locations(lon, lan, locations_dict, map_title='Map'):
# Create a map centered at the first location
m = folium.Map(location=[lon, lan], zoom_start=15)

# Add red marker for the given lon, lan
folium.Marker(location=[lon, lan], popup='Pinned Location', icon=folium.Icon(color='red')).add_to(m)

# Add blue markers for each location in the dictionary
for key, value in locations_dict.items():
folium.Marker(location=value, popup=f'{key}: {value}', icon=folium.Icon(color='blue')).add_to(m)

# Save the map to an HTML file
file_path = map_title + '.html'
m.save(file_path)

# Open the HTML file using the default web browser
try:
webbrowser.open('file://' + os.path.realpath(file_path))
except Exception as e:
print("Unable to open HTML file:", e)

def show_map(vlon, vlan, location_dict):
pin_locations(vlon, vlan, location_dict,'Pinned_Locations')
3 changes: 3 additions & 0 deletions new-version/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
36 changes: 36 additions & 0 deletions new-version/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions new-version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
4 changes: 4 additions & 0 deletions new-version/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
Loading