Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #117

Merged
merged 10 commits into from
May 12, 2024
Merged
6 changes: 1 addition & 5 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ name = "csharp"
name = "javascript"

[analyzers.meta]
plugins = ["angular"]


[analyzers.meta]
runtime_version = "3.x.x"
plugins = ["angular"]
78 changes: 39 additions & 39 deletions Core/Resgrid.Model/MapIconTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,83 +58,83 @@ public static string ConvertTypeToName(MapIconTypes type)
case MapIconTypes.Search:
return "search";
case MapIconTypes.Blast:
return "";
return "blast";
case MapIconTypes.CarAccident:
return "";
return "caraccident";
case MapIconTypes.CrimeScene:
return "";
return "crimescene";
case MapIconTypes.Earthquake:
return "";
return "earthquake";
case MapIconTypes.EmergencyPhone:
return "";
return "emergencyphone";
case MapIconTypes.Fire:
return "";
return "fire";
case MapIconTypes.FirstAid:
return "";
return "firstaid";
case MapIconTypes.Flood:
return "";
return "flood";
case MapIconTypes.Tools:
return "";
return "tools";
case MapIconTypes.LineDown:
return "";
return "linedown";
case MapIconTypes.Industry:
return "";
return "industry";
case MapIconTypes.PowerOutage:
return "";
return "poweroutage";
case MapIconTypes.Radiation:
return "";
return "radiation";
case MapIconTypes.Shooting:
return "";
return "shooting";
case MapIconTypes.Poison:
return "";
return "poison";
case MapIconTypes.Gathering:
return "";
return "gathering";
case MapIconTypes.TreeDown:
return "";
return "treedown";
case MapIconTypes.Worksite:
return "";
return "worksite";
case MapIconTypes.Workshop:
return "";
return "workshop";
case MapIconTypes.Aircraft:
return "";
return "aircraft";
case MapIconTypes.Ambulance:
return "";
return "ambulance";
case MapIconTypes.Bulldozer:
return "";
return "bulldozer";
case MapIconTypes.Bus:
return "";
return "bus";
case MapIconTypes.Car:
return "";
return "car";
case MapIconTypes.CarTwo:
return "";
return "car2";
case MapIconTypes.Check:
return "";
return "check";
case MapIconTypes.Flag:
return "";
return "flag";
case MapIconTypes.FourByFour:
return "";
return "fourbyfour";
case MapIconTypes.Group:
return "";
return "group";
case MapIconTypes.Helicopter:
return "";
return "helicopter";
case MapIconTypes.Motorcycle:
return "";
return "motorcycle";
case MapIconTypes.Pickup:
return "";
return "pickup";
case MapIconTypes.Camper:
return "";
return "camper";
case MapIconTypes.Plowtruck:
return "";
return "plowtruck";
case MapIconTypes.Tires:
return "";
return "tires";
case MapIconTypes.Truck:
return "";
return "truck";
case MapIconTypes.Van:
return "";
return "van";
case MapIconTypes.Velocimeter:
return "";
return "velocimeter";
case MapIconTypes.Watercraft:
return "";
return "watercraft";
}

return "";
Expand Down
25 changes: 23 additions & 2 deletions Core/Resgrid.Services/DepartmentLinksService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,33 @@ public async Task<List<DepartmentLink>> GetAllLinksForDepartmentAsync(int depart
{
var links = await _departmentLinksRepository.GetAllLinksForDepartmentAsync(departmentId);

return links.ToList();
if (links != null && links.Any())
{
foreach (var link in links)
{
link.Department = await _departmentsRepository.GetByIdAsync(link.DepartmentId);
link.LinkedDepartment = await _departmentsRepository.GetByIdAsync(link.DepartmentLinkId);
}

return links.ToList();
}

return new List<DepartmentLink>();
}

public async Task<DepartmentLink> GetLinkByIdAsync(int linkId)
{
return await _departmentLinksRepository.GetByIdAsync(linkId);
var link = await _departmentLinksRepository.GetByIdAsync(linkId);

if (link != null)
{
link.Department = await _departmentsRepository.GetByIdAsync(link.DepartmentId);
link.LinkedDepartment = await _departmentsRepository.GetByIdAsync(link.DepartmentLinkId);

return link;
}

return null;
}

public async Task<DepartmentLink> SaveAsync(DepartmentLink link, CancellationToken cancellationToken = default(CancellationToken))
Expand Down
4 changes: 4 additions & 0 deletions Docker/resgrid.env
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ RESGRID__MappingConfig__GoogleMapsJSKey=
# https://developers.google.com/maps/documentation/geocoding/get-api-key
RESGRID__MappingConfig__GoogleMapsApiKey=

# MapTiler API Key
# https://www.maptiler.com/
RESGRID__MappingConfig__OSMKey=

# what 3 words api key
# https://developer.what3words.com/public-api
RESGRID__MappingConfig__What3WordsApiKey=
Expand Down
18 changes: 9 additions & 9 deletions Providers/Resgrid.Providers.Geo/GeoLocationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ public async Task<Coordinates> GetCoordinatesFromW3W(string words)
try
{
var client = new RestClient("https://api.what3words.com");
var request = new RestRequest($"/v2/forward?key={Config.MappingConfig.What3WordsApiKey}&lang=en&addr={words}", Method.Get);
var request = new RestRequest($"/v3/convert-to-coordinates?key={Config.MappingConfig.What3WordsApiKey}&addr={words}", Method.Get);

var response = await client.ExecuteAsync<W3WResponse>(request);

if (response.Data != null && response.Data.geometry != null)
if (response.Data != null && response.Data.coordinates != null)
{
var coords = new Coordinates();
coords.Latitude = response.Data.geometry.lat;
coords.Longitude = response.Data.geometry.lng;
coords.Latitude = response.Data.coordinates.lat;
coords.Longitude = response.Data.coordinates.lng;

return coords;
}
Expand All @@ -268,15 +268,15 @@ public async Task<Coordinates> GetCoordinatesFromW3WAsync(string words)
try
{
var client = new RestClient("https://api.what3words.com");
var request = new RestRequest($"/v2/forward?key={Config.MappingConfig.What3WordsApiKey}&lang=en&addr={words}", Method.Get);
var request = new RestRequest($"/v3/convert-to-coordinates?key={Config.MappingConfig.What3WordsApiKey}&addr={words}", Method.Get);

var response = await client.ExecuteAsync<W3WResponse>(request);

if (response.Data != null && response.Data.geometry != null)
if (response.Data != null && response.Data.coordinates != null)
{
var coords = new Coordinates();
coords.Latitude = response.Data.geometry.lat;
coords.Longitude = response.Data.geometry.lng;
coords.Latitude = response.Data.coordinates.lat;
coords.Longitude = response.Data.coordinates.lng;

return coords;
}
Expand All @@ -296,7 +296,7 @@ public async Task<string> GetW3WFromCoordinates(Coordinates coordinates)
try
{
var client = new RestClient("https://api.what3words.com");
var request = new RestRequest($"/v2/reverse?key={Config.MappingConfig.What3WordsApiKey}&coords={$"{coordinates.Latitude},{coordinates.Longitude}"}", Method.Get);
var request = new RestRequest($"/v3/convert-to-3wa?key={Config.MappingConfig.What3WordsApiKey}&coords={$"{coordinates.Latitude},{coordinates.Longitude}"}", Method.Get);

var response = await client.ExecuteAsync<ReverseW3WResponse>(request);

Expand Down
6 changes: 2 additions & 4 deletions Providers/Resgrid.Providers.Geo/W3WResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ public class W3WResponse
{
public string type { get; set; }
public string words { get; set; }
public Geometry geometry { get; set; }
public Geometry coordinates { get; set; }
public string language { get; set; }
public string map { get; set; }
public dynamic crs { get; set; }
public dynamic bounds { get; set; }
}

public class ReverseW3WResponse
{
public string type { get; set; }
public string words { get; set; }
public Geometry geometry { get; set; }
public Geometry coordinates { get; set; }
public string language { get; set; }
public string map { get; set; }
public dynamic crs { get; set; }
public dynamic bounds { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,12 @@ public async Task<ActionResult<GetMapDataResult>> GetMapDataAndMarkers()
{
var type = callTypes.FirstOrDefault(x => x.Type == call.Type);

if (type != null && type.MapIconType.HasValue)
info.ImagePath = ((MapIconTypes)type.MapIconType.Value).ToString();
}
if (type != null && type.MapIconType.HasValue)
info.ImagePath = MapIcons.ConvertTypeToName((MapIconTypes)type.MapIconType.Value);
}
// if (type != null && type.MapIconType.HasValue)
// info.ImagePath = ((MapIconTypes)type.MapIconType.Value).ToString();
//}

if (!String.IsNullOrEmpty(call.GeoLocationData) && call.GeoLocationData.Length > 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class MapComponent implements OnInit {

if (!this.map) {
var osm = L.tileLayer(
this.leafletosmurl,
this.leafletosmurl+window['rgOsmKey'],
{
maxZoom: 19,
attribution: this.mapattribution,
Expand Down Expand Up @@ -308,7 +308,7 @@ export class MapComponent implements OnInit {
{
icon: L.icon({
iconUrl:
'/images/mapping/' + markerInfo.ImagePath + '.png',
'/images/Mapping/' + markerInfo.ImagePath + '.png',
iconSize: [32, 37],
iconAnchor: [16, 37],
}),
Expand All @@ -327,7 +327,7 @@ export class MapComponent implements OnInit {
{
icon: L.icon({
iconUrl:
'/images/mapping/' + markerInfo.ImagePath + '.png',
'/images/Mapping/' + markerInfo.ImagePath + '.png',
iconSize: [32, 37],
iconAnchor: [16, 37],
}),
Expand Down
Loading