IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Unverified Commit e3bf4cc0 authored by Jared's avatar Jared Committed by GitHub
Browse files

Requested changes from Anthony (#81)

parent 6a27dbd5
......@@ -131,4 +131,5 @@ describe('geometrySearch.controller.polygonFind', () => {
expect(next).toHaveBeenCalledWith(DB_ERROR);
expect(res.json).not.toHaveBeenCalled();
});
});
\ No newline at end of file
});
......@@ -70,4 +70,3 @@ module.exports = {
polygonFind
};
......@@ -78,4 +78,5 @@ describe('geometrySearch.db.polygonFind', () => {
expect(query.mock.calls[0][0]).toEqual(expect.stringContaining('ST_Within(a.location, ST_MakePolygon(ST_GeomFromText($1)))'));
expect(query.mock.calls[0][1][0]).toEqual(expect.stringContaining(lineString));
});
});
\ No newline at end of file
});
const utils = require('../utils');
const QUERY_FIND = `
SELECT
sponsor.name AS sponsor_name,
project.name AS project_name,
asset.id AS asset_id,
asset_type.name AS asset_type,
asset_type.description AS asset_description,
ST_Y(asset.location) AS latitude,
ST_X(asset.location) AS longitude
FROM
asset
JOIN project ON asset.project_id = project.id
JOIN sponsor ON project.sponsor_id = sponsor.id
JOIN asset_type ON asset.asset_type_id = asset_type.id
WHERE
TRUE `;
SELECT
sponsor.name AS sponsor_name,
project.name AS project_name,
asset.id AS asset_id,
asset_type.name AS asset_type,
asset_type.description AS asset_description,
ST_Y(asset.location) AS latitude,
ST_X(asset.location) AS longitude
FROM
asset
JOIN project ON asset.project_id = project.id
JOIN sponsor ON project.sponsor_id = sponsor.id
JOIN asset_type ON asset.asset_type_id = asset_type.id
WHERE
TRUE `;
/**
* Find project assets.
......
......@@ -146,8 +146,9 @@ const validLongitude = (longitude) => {
const parseCoordinates = (coordinateList) => {
// There needs to be at least 3
if (coordinateList.length < 3)
if (coordinateList.length < 3) {
return ParseResult.failure('Expected at least 3 points in the coordinates list');
}
let lat = 0;
let lon = 0;
......@@ -156,19 +157,16 @@ const parseCoordinates = (coordinateList) => {
var i;
var point;
for(i = 0; i < coordinateList.length; i++)
{
for (i = 0; i < coordinateList.length; i++) {
point = coordinateList[i];
lon = parseFloat(point.longitude);
lat = parseFloat(point.latitude);
if(!isNaN(lon) && validLongitude(lon)
&& !isNaN(lat) && validLatitude(lat))
{
if (!isNaN(lon) && validLongitude(lon)
&& !isNaN(lat) && validLatitude(lat)) {
coordinates.push({latitude: lat, longitude: lon});
}
else
{
else {
return ParseResult.failure('Unable to parse coordinate. Please format points like {coordinates: [{"latitude": "-14.342", "longitude": "33.123"},...]}');
}
}
......@@ -380,4 +378,4 @@ module.exports = {
},
ParseResult
};
\ No newline at end of file
};
......@@ -78,4 +78,5 @@ module.exports = {
commitTransaction,
rollbackTransaction,
makeLineString
};
\ No newline at end of file
};
......@@ -4,4 +4,5 @@
<c-map onready={onMapInitialized}></c-map>
</div>
</lightning-card>
</template>
\ No newline at end of file
</template>
......@@ -6,8 +6,8 @@ import utils from 'c/utils';
const DISTANCE_URL = utils.URL + 'assets/geometrySearch/distance';
// import { assets, bboxAssets } from 'c/controllers';
// import { markerFromAsset } from './utils';
// TODO import { assets, bboxAssets } from 'c/controllers';
// TODO import { markerFromAsset } from './utils';
/* L is the Leaflet object constructed by the leaflet.js script */
/*global L*/
......@@ -58,17 +58,14 @@ export default class GeoQuery extends LightningElement {
map.on('click', function(e) {
// Remove the old radius search indicator so we can start a new query
if (this.mapCircle !== undefined)
{
if (this.mapCircle !== undefined) {
map.removeLayer(this.mapCircle);
}
// Remove the old markers from the previous query
if (this.myAssets !== undefined && this.myAssets.length > 0)
{
if (this.myAssets !== undefined && this.myAssets.length > 0){
let i;
for(i = 0; i < this.myAssets.length; i++)
{
for (i = 0; i < this.myAssets.length; i++) {
map.removeLayer(this.myAssets[i]);
}
......@@ -123,14 +120,13 @@ export default class GeoQuery extends LightningElement {
console.log(response);
// Initialize the array if need be
if( this.myAssets === undefined){
if ( this.myAssets === undefined) {
this.myAssets = [];
}
// Iterate over the assets and add them to the map
let i;
for(i = 0; i < response.length; i++)
{
for (i = 0; i < response.length; i++) {
const a = response[i];
// Create the map marker. Add back the offset so markers appear where the user clicked.
......@@ -146,4 +142,5 @@ export default class GeoQuery extends LightningElement {
});
// this.map.on('click', this.onMapClicked);
}
}
\ No newline at end of file
}
......@@ -12,4 +12,5 @@
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
</LightningComponentBundle>
\ No newline at end of file
</LightningComponentBundle>
......@@ -29,7 +29,6 @@ export default class Map extends LightningElement {
});
}
/**
* Constructs the Leaflet map on the page and initializes this.map
*/
......@@ -40,10 +39,8 @@ export default class Map extends LightningElement {
L.control.scale().addTo(this.map);
this.map.setMinZoom(2);
this.map.setMaxZoom(17);
}
/**
* Setup the base OpenStreetMap tile layer
*/
......@@ -54,8 +51,7 @@ export default class Map extends LightningElement {
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
attribution: '&copy; ' + mapLink + ' Contributors',
})
.addTo(this.map);
}
}
\ No newline at end of file
}
const URL = 'https://my-conservation-life-dev4.herokuapp.com/api/v1/';
const URL = 'https://my-conservation-life.herokuapp.com/api/v1/';
export { URL };
.marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6);
}
......@@ -8,6 +9,7 @@
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
}
......@@ -15,6 +17,7 @@
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6);
}
......@@ -23,6 +26,7 @@
.leaflet-oldie .marker-cluster-small {
background-color: rgb(181, 226, 140);
}
.leaflet-oldie .marker-cluster-small div {
background-color: rgb(110, 204, 57);
}
......@@ -30,6 +34,7 @@
.leaflet-oldie .marker-cluster-medium {
background-color: rgb(241, 211, 87);
}
.leaflet-oldie .marker-cluster-medium div {
background-color: rgb(240, 194, 12);
}
......@@ -37,14 +42,16 @@
.leaflet-oldie .marker-cluster-large {
background-color: rgb(253, 156, 115);
}
.leaflet-oldie .marker-cluster-large div {
background-color: rgb(241, 128, 23);
}
}
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
......@@ -55,6 +62,8 @@
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 30px;
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment