Skip to content

Commit

Permalink
add depency, production build, bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zachbf committed Jan 29, 2023
1 parent 688b647 commit a125706
Show file tree
Hide file tree
Showing 18 changed files with 1,812 additions and 96 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14
FROM node:16

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -10,7 +10,7 @@ COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
RUN npm ci --only=production

# Bundle app source
COPY . .
Expand Down
137 changes: 67 additions & 70 deletions atc.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,87 +242,84 @@ export async function getOnlinePositions() {

// SY_APP 124.400 AFV 124400000
// iterate txvrs.element.transceivers.element frequency/1000000
if(stations){
stations.forEach(function(station, index){
// Keep only CTR, APP, and TWR.
if(station.callsign.toUpperCase().includes("CTR") === false && station.callsign.toUpperCase().includes("APP") === false && station.callsign.toUpperCase().includes("TWR") === false){
delete stations[index];
}else{

// Join sectors by callsign
var sector = sectors.find(function cb(element){
if(element.Callsign === station.callsign){

// Check std sectors and load sub sectors.
if(element.standard_position === true && element.responsibleSectors.length > 0){
sectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);

onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(element));
}

// check if other frequencies are active and show them as online.
// this only works for ENR sectors.

var activeFrequencies = [];
station.transceivers.forEach(function(element){
// Hertz to Megahurts
element.frequency = element.frequency/1000000;
activeFrequencies.push(element.frequency.toFixed(3));
})

activeFrequencies = uniq(activeFrequencies);
var type = station.callsign.toUpperCase().includes("CTR");
stations.forEach(function(station, index){
// Keep only CTR, APP, and TWR.
if(station.callsign.toUpperCase().includes("CTR") === false && station.callsign.toUpperCase().includes("APP") === false && station.callsign.toUpperCase().includes("TWR") === false){
delete stations[index];
}else{

// Join sectors by callsign
var sector = sectors.find(function cb(element){
if(element.Callsign === station.callsign){

// Check std sectors and load sub sectors.
if(element.standard_position === true && element.responsibleSectors.length > 0){
sectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);

onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(element));
}

// check if other frequencies are active and show them as online.
// this only works for ENR sectors.

var activeFrequencies = [];
station.transceivers.forEach(function(element){
// Hertz to Megahurts
element.frequency = element.frequency/1000000;
activeFrequencies.push(element.frequency.toFixed(3));
})

if(activeFrequencies.length > 1 && type){
if(activeFrequencies.length > 1){

activeFrequencies.forEach(function(frequency){
sectors.find(function cb(element){
activeFrequencies.forEach(function(frequency){
sectors.find(function cb(element){

activeFrequencies = uniq(activeFrequencies);
var type = station.callsign.toUpperCase().includes("CTR");

if(element.Frequency == frequency && element.Callsign != station.callsign){
if(element.Frequency == frequency && element.Callsign != station.callsign && type){

var subSectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);
var subSectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);

var poly1 = turf.polygon(sectorWithSubsectors.geometry.coordinates)
var poly2 = turf.polygon(subSectorWithSubsectors.geometry.coordinates)
var intersection = turf.booleanOverlap(poly1, poly2)
var poly1 = turf.polygon(sectorWithSubsectors.geometry.coordinates)
var poly2 = turf.polygon(subSectorWithSubsectors.geometry.coordinates)

var intersection = turf.booleanOverlap(poly1, poly2)

if(intersection){
onlineSectors.push(subSectorWithSubsectors);
}
if(intersection){
onlineSectors.push(subSectorWithSubsectors);
}
}

})
})
})
}
};
});

/*
if(activePosition !== false){
// Join sectors by frequency
// TODO - How to incrementally add sectors working outwards from the logged on sector?
var extendedPoly = activePosition;
activeFrequncies.forEach(function(element){
var adjacentSector = isAdjacentSector(element, extendedPoly, sectors);
if(adjacentSector !== false){
extendedPoly = unionArray([extendedPoly, sectorWithSubsectors])
if(adjacentSector.standard_position === true){
var sectorWithSubsectors = mergeSectors(adjacentSector, adjacentSector.responsibleSectors,sectors);
onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(adjacentSector));
}
};
});

/*
if(activePosition !== false){
// Join sectors by frequency
// TODO - How to incrementally add sectors working outwards from the logged on sector?
var extendedPoly = activePosition;
activeFrequncies.forEach(function(element){
var adjacentSector = isAdjacentSector(element, extendedPoly, sectors);
if(adjacentSector !== false){
extendedPoly = unionArray([extendedPoly, sectorWithSubsectors])
if(adjacentSector.standard_position === true){
var sectorWithSubsectors = mergeSectors(adjacentSector, adjacentSector.responsibleSectors,sectors);
onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(adjacentSector));
}
}
})
}
*/
}
})
}
})
}

*/
}
})

return turf.featureCollection(uniq(onlineSectors));
}
4 changes: 2 additions & 2 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export async function getVatsimData () {
var ttlMs = cache.getTtl('getVatsimData');
let data;
// VATSIM data is refreshed every 15s. Check 10s out from expiry.
if (ttlMs == undefined || ttlMs - Date.now() <= 10000) {
if (ttlMs == undefined || ttlMs < Date.now()) {
try{
// Download fresh VATSIM data
if(ttlMs == undefined){
Expand Down Expand Up @@ -260,7 +260,7 @@ export async function getVatsimAFV () {
/*var getUrl = uniqueRandomArray(vatsimServers.data.transceivers);
var url = getUrl();*/
var url = config.get('data.vatsim.transceiversUrl');
log.debug(`VATSIM data URL: ${url}`);
//log.debug(`VATSIM data URL: ${url}`);
var ttlMs = cache.getTtl('getVatsimAFV');
let data;
// VATSIM data is refreshed every 15s. Check 10s out from expiry.
Expand Down
1 change: 1 addition & 0 deletions dependencies/query-overpass-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
5 changes: 5 additions & 0 deletions dependencies/query-overpass-master/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- '8'
- '10'
- '12'
7 changes: 7 additions & 0 deletions dependencies/query-overpass-master/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## ISC License

Copyright (c) 2014, Per Liedman <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
90 changes: 90 additions & 0 deletions dependencies/query-overpass-master/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
## A few words on diversity in tech

[![Greenkeeper badge](https://badges.greenkeeper.io/perliedman/query-overpass.svg)](https://greenkeeper.io/)

I need to take some of your time. I can't believe we let shit like [the Kathy Sierra incident](http://www.wired.com/2014/10/trolls-will-always-win/) or [what happened to Brianna Wu](https://twitter.com/Spacekatgal/status/520739878993420290) happen over and over again. I can't believe we, the open source community, let [sexist, misogynous shit happen over and over again](http://geekfeminism.wikia.com/wiki/Timeline_of_incidents).

I strongly believe that it is my &mdash; and your &mdash; duty to make the open source community, as well as the tech community at large, a community where everyone feel welcome and is accepted. At the very minimum, that means making sure the community and its forums both _are_ safe, and are perceived as safe. It means being friendly and inclusive, even when you disagree with people. It means not shrugging off discussions about sexism and inclusiveness with [handwaving about censorship and free speech](https://josm.openstreetmap.de/ticket/10568). For a more elaborate document on what that means, [the NPM Code of Conduct](http://www.npmjs.com/policies/conduct) is a good start, [Geek Feminism's resources for allies](http://geekfeminism.wikia.com/wiki/Resources_for_allies) contains much more.

While I can't force anyone to do anything, if you happen to disagree with this, I ask of you not to use any of the open source I have published. Nor am I interested in contributions from people who can't accept or act respectfully towards other humans regardless of gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics. If you think feminism, anti-racism or the LGBT movement is somehow wrong, disturbing or irrelevant, I ask you to go elsewhere to find software.

# query-overpass [![NPM version](https://badge.fury.io/js/query-overpass.svg)](http://badge.fury.io/js/query-overpass) [![Build Status](https://travis-ci.org/perliedman/query-overpass.svg?branch=master)](https://travis-ci.org/perliedman/query-overpass)

Make queries to [OpenStreetMap](http://www.openstreetmap.org/)'s [overpass API](http://wiki.openstreetmap.org/wiki/Overpass_API) and output as [GeoJSON](http://geojson.org/).

## cli

install:

```bash
$ npm install -g query-overpass
```

use (Bash):

```bash
$ echo 'node(57.7,11.9,57.8,12.0)[amenity=bar];out;' | query-overpass
```

use (Windows cmd):
```bat
$ echo node(57.7,11.9,57.8,12.0)[amenity=bar];out; | query-overpass
```

Optionally, a file containing the query can be passed as the first argument:

```bash
$ query-overpass query.ql
```

Goes well together with other command line tools, like for example [geojsonio-cli](https://github.com/mapbox/geojsonio-cli):

```bash
$ npm install -g geojsonio-cli
$ echo 'node(57.7,11.9,57.8,12.0)[amenity=bar];out;' | query-overpass | geojsonio
```

You can also provide the URL where the Overpass API is located:

```bash
$ query-overpass --overpass-url http://my.overpass-provider.org/
```

The default is to use `https://overpass-api.de/api/interpreter`.

You can also flatten each GeoJSON feature, making it more easily processable by other software and tools

```bash
$ query-overpass --flat-properties
```

The default behaviour, without adding `--flat-properties` is to use `false` to be consistent with previous version.

## usage

Installation is easy with npm:

```bash
$ npm install query-overpass
```

## api

query-overpass exports a single function:

### query_overpass(query, callback, options)

Performs the provided query and calls the callback when done. The callback is of the form

```javascript
callback(error, data)
```

Where error is an object containing `message` and `statusCode` if an error occured, or `undefined` if
no error occured. `data` will be the query response as an GeoJSON object.

The options supported at the moment are

* `overpassUrl` which defaults to `'https://overpass-api.de/api/interpreter'` unless specified.
* `flatProperties` which defaults to `false`.
* `userAgent` which defaults to `node.js query-overpass` unless specified.
35 changes: 35 additions & 0 deletions dependencies/query-overpass-master/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

var concat = require('concat-stream'),
argv = require('minimist')(process.argv.slice(2), {
string: 'overpass-url',
boolean: 'flat-properties',
boolean: 'version',
default: {
'flat-properties': false
}
}),
fs = require('fs'),
overpass = require('./');

if (argv['version']) {
process.stdout.write(require('./package.json').version+'\n');
process.exit(0);
}

function openData(s) {
var query = s.toString();
overpass(query, function(err, geojson) {
if (!err) {
console.log(JSON.stringify(geojson));
} else {
console.error(err);
process.exit(1);
}
}, {
overpassUrl: argv['overpass-url'],
flatProperties: argv['flat-properties']
});
}

((argv._[0] && fs.createReadStream(argv._[0])) || process.stdin).pipe(concat(openData));
Loading

0 comments on commit a125706

Please sign in to comment.