Skip to content

Commit

Permalink
improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerg Roth committed Sep 26, 2024
1 parent 255bfb9 commit aaef908
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions lib/createKml.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

exports.getHeader = async function(category) {
exports.getHeader = async function(category, solid) {
let header = [];
header.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
header.push("<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">");
header.push("<Document>");
header.push(" <name>" + category.charAt(0).toUpperCase() + category.slice(1).toLowerCase() + " UVG Grid</name>");
header.push(" <name>" + category.charAt(0).toUpperCase() + category.slice(1).toLowerCase() + " " + solid.charAt(0).toUpperCase() + solid.slice(1).toLowerCase() + "</name>");
return header;
}

Expand Down Expand Up @@ -37,7 +37,7 @@ exports.getStyle = async function(solids, category, solid, type, styles) {
style.push(" <Style id=\"" + category + "-" + solid + "-" + type + "0\">");
style.push(" <LineStyle>");
style.push(" <color>" + rgb + "</color>");
style.push(" <width>" + solids['distance']/15000 + "</width>");
style.push(" <width>" + solids['distance']/20000 + "</width>");
style.push(" </LineStyle>");
style.push(" </Style>");
style.push(" <Style id=\"highlight0\">");
Expand All @@ -52,19 +52,20 @@ exports.getStyle = async function(solids, category, solid, type, styles) {
exports.getGeometry = async function(solids, points, category, solid, type, latitude, longitude, bearing, form) {
var geometry = [];
if (type == "points") {
let newPoints = await getPoints(points);
let newPoints = await getPoints(points, solid, latitude, longitude, bearing);
geometry = await geometry.concat(newPoints);
} else {
let newLines = await getLines(solids['lines'], points, category, solid, type);
let newLines = await getLines(solids['lines'], points, category, solid, type, latitude, longitude, bearing);
geometry = await geometry.concat(newLines);
};
return geometry;
};

async function getLines(lines, points, category, solid, type) {
async function getLines(lines, points, category, solid, type, latitude, longitude, bearing) {
let lineStrings = [];
lineStrings.push(" <Folder>");
lineStrings.push(" <name>" + type.charAt(0).toUpperCase() + type.slice(1).toLowerCase() + " Lines</name>");
lineStrings.push(" <name>" + solid.charAt(0).toUpperCase() + solid.slice(1).toLowerCase() + " Lines</name>");
lineStrings.push(" <description>Latitude: " + latitude + "<br/>Longitude: " + longitude + "<br/>Bearing: " + bearing + "</description>");
for (let i = 0; i < lines.length; i++) {
lineStrings.push(" <Placemark>");
lineStrings.push(" <name>" + lines[i][0] + " - " + lines[i][1] + "</name>");
Expand All @@ -81,10 +82,11 @@ async function getLines(lines, points, category, solid, type) {
return lineStrings;
};

async function getPoints(points) {
async function getPoints(points, solid, latitude, longitude, bearing) {
let pointString = [];
pointString.push(" <Folder>");
pointString.push(" <name>Points</name>");
pointString.push(" <name>" + solid.charAt(0).toUpperCase() + solid.slice(1).toLowerCase() + "</name>");
pointString.push(" <description>Latitude: " + latitude + "<br/>Longitude: " + longitude + "<br/>Bearing: " + bearing + "</description>");
for (let i = 0; i < points.length; i++) {
pointString.push(" <Placemark>");
pointString.push(" <name>Point " + i + "</name>");
Expand Down
2 changes: 1 addition & 1 deletion lib/leylines.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ exports.exportGrid = async function(req, res, pool) {
styles['highlight']['width'] = 5;

var kmlfile = []
var kmlHeader = await kml.getHeader(category);
var kmlHeader = await kml.getHeader(category, solid);
var kmlFooter = await kml.getFooter();
if (type == "lines") {
var kmlStyleMap = await kml.getStyleMap(category, solid, type);
Expand Down

0 comments on commit aaef908

Please sign in to comment.