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
51 changes: 51 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cctvpt.w3k.io
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Web based (JavaScript) planner tool for CCTV using OpenStreetMaps/Google maps and some point-and-click camera placement. You can choose FOV, Range, etc.

[Online Demo](https://thejosh.github.io/cctv/)
[Online Demo](https://CCTVPT.w3K.io/)
<br><br>

![screen_20240111-230657](https://github.com/TheJosh/cctv/assets/1219314/3f092874-b719-4121-9f4c-f3452ad78fbe)
Expand Down
46 changes: 45 additions & 1 deletion cctv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Let's do this...
var colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF', '#C0C0C0', '#808080', '#800000', '#808000', '#008000', '#800080', '#008080', '#000080', '#4B0082', '#7CFC00', '#ADFF2F', '#7FFF00', '#D2691E', '#8B4513', '#A52A2A', '#DEB887', '#5F9EA0', '#7F007F', '#D02090', '#FFD700', '#8B008B', '#556B2F', '#FF8C00', '#9932CC', '#8B0000', '#E9967A'];
var toolsEl = document.getElementById('tools');
var cameras = [];
var currentCam = null;
Expand Down Expand Up @@ -66,6 +68,8 @@ function calcFov(sensorSize, focalLength) {
* Set the current camera in the tools panel
*/
function setCurrent(cam) {
var colorPaletteHtml = colors.map(color => `<div class="color-square" style="background-color: ${color};" onclick="changeColor('${color}')"></div>`).join('');

toolsEl.innerHTML = `
${cam.position.lat}<br>${cam.position.lng}
<br>
Expand All @@ -76,6 +80,8 @@ function setCurrent(cam) {
<br>
<br>Range: <input type="range" min="1" max="100" id="fld-range" value="${cam.range}"> meters
<br>FOV: <input type="range" min="1" max="359" id="fld-fov" value="${cam.fov}"> degrees
<br>
<br>Color: <div id="color-palette">${colorPaletteHtml}</div>
`;

document.getElementById('fld-angle').addEventListener('input', (e) => { cam.angle = parseFloat(e.target.value); renderCam(cam) });
Expand All @@ -85,6 +91,22 @@ function setCurrent(cam) {
currentCam = cam;
}



function changeColor(color) {
if (currentCam) {
currentCam.ndPolygon.setStyle({
color: color,
fillColor: color
});
currentCam.ndCentre.setStyle({
color: color,
fillColor: color
});
}
}


function renderCam(cam) {
var coords = buildPolyCoords(cam.position, cam.angle, cam.fov, cam.range);
cam.ndPolygon.setLatLngs(coords);
Expand All @@ -99,7 +121,7 @@ function startMapCoords() {
if (lat && lng && z) {
return [lat, lng, z];
} else {
return [-34.9285, 138.6007, 12];
return [26.528691713882818, -80.0643789768219, 18];
}
}

Expand All @@ -113,6 +135,19 @@ function setUrlCoords(map) {
}


// Function to remove the current camera
function removeCurrentCamera() {
if (currentCam) {
currentCam.ndPolygon.remove();
currentCam.ndCentre.remove();
cameras = cameras.filter(cam => cam !== currentCam);
currentCam = null;
toolsEl.innerHTML = '';
}
}


// Initialize Program
function init() {
// OpenStreetMap
var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
Expand Down Expand Up @@ -146,4 +181,13 @@ function init() {
}


// Call 'saveState' whenever the state changes and monitor DEL key at the same time.
document.addEventListener('keydown', function(event) {
if (event.key === 'Delete') {
removeCurrentCamera();
}
});


// Rock N Roll
init();
16 changes: 0 additions & 16 deletions index.htm

This file was deleted.

49 changes: 49 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<title>CCTV Placement Tool</title>
<link rel="stylesheet" href="./leaflet/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
<script src="./leaflet/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script src="./leaflet/leaflet.geometryutil.min.js"></script>
<style>
#color-palette {
display: grid;
grid-template-columns: repeat(8, 1fr); /* This creates 8 columns */
grid-gap: 10px; /* This adds some space between the squares */
width: 100%; /* This ensures the color palette takes up the full width of its container */
}

.color-square {
width: 20px;
height: 20px;
cursor: pointer; /* This changes the cursor to a hand when hovering over a square */
margin: 5px auto; /* This centers the squares and adds some vertical space between them */
}

.container {
display: grid;
grid-template-columns: 1fr 400px; /* Left takes up viewport height minus 50px, right has fixed width */
gap: 20px; /* Gap between left and right content */
}

.container-left {
border: 2px solid #e50000; /* Add border to left content */
height: calc(100vh - 20px); /* Adjust height to take up viewport height minus 50px */
}

@media screen and (max-width: 1000px) {
.container {
grid-template-columns: 1fr; /* Single column layout for smaller screens */
}
}

</style>
</head>
<body>
<div class="container">
<div class="container-left" id="map" style="width: 100%; float: left;"></div>
<div class="container-right" id="tools" style="width: 400px; float: right;"></div>
</div>
<script src="cctv.js"></script>
</body>
</html>
Binary file added leaflet/images/layers-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added leaflet/images/layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added leaflet/images/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added leaflet/images/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added leaflet/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading