versx / WhMgr

Discord notification system that works with RealDeviceMap and reports Pokemon, Raids, Eggs, Quests, Pokestop Lures, Team Rocket Invasions, Gym team changes, and Weather as embed messages. Discord users can also subscribe to custom Pokemon, Raid, Quest, Team Rocket Invasion, and Pokestop Lure notifications via direct message (DM) with predefined requirements.
25 stars 27 forks source link

v5 geojson geofences #191

Closed clburlison closed 2 years ago

clburlison commented 2 years ago

When your config is using geojson for geofences

  "geofences": [
      "tmm.json"
  ],

Whmgr v5 is unable to process this. I was able to replicate this with my main two server geojson files plus the documentation example

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": 12143584,
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -117.185508,
                            34.05361
                        ],
                        [
                            -117.185397,
                            34.05366
                        ],
                        [
                            -117.185326,
                            34.053564
                        ],
                        [
                            -117.184819,
                            34.053828
                        ],
                        [
                            -117.184457,
                            34.054009
                        ],
                        [
                            -117.18409,
                            34.05353
                        ],
                        [
                            -117.184027,
                            34.053448
                        ],
                        [
                            -117.184991,
                            34.052942
                        ],
                        [
                            -117.185508,
                            34.05361
                        ]
                    ]
                ]
            },
            "properties": {
                "enabled": true,
                "name": "Unknown Areaname",
                "stroke": "#352BFF",
                "stroke-width": 2.0,
                "stroke-opacity": 1.0,
                "fill": "#0651FF",
                "fill-opacity": 0.5,
                "priority": 2,
            }
        }
    ]
}

Error message

whmgr@whmgr:~/test/bin$ dotnet WhMgr.dll 
Could not load Geofence file tmm.json (for server XXXX):
System.Text.Json.JsonException: The JSON value could not be converted to NetTopologySuite.Features.FeatureCollection. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.Serialization.Converters.IEnumerableDefaultConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at WhMgr.Extensions.JsonExtensions.FromJson[T](String json) in /home/whmgr/test/src/Extensions/JsonExtensions.cs:line 16
   at WhMgr.Services.Geofence.Geofence.FromJsonFile(String filePath) in /home/whmgr/test/src/Services/Geofence/Geofence.cs:line 110
   at WhMgr.Services.Geofence.Geofence.FromFile(String filePath) in /home/whmgr/test/src/Services/Geofence/Geofence.cs:line 100
   at WhMgr.Configuration.Config.LoadGeofences(Dictionary`2 servers) in /home/whmgr/test/src/Configuration/Config.cs:line 222
Could not load Geofence file tmm.json (for server 480799758810742824):
System.Text.Json.JsonException: The JSON value could not be converted to NetTopologySuite.Features.FeatureCollection. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.Serialization.Converters.IEnumerableDefaultConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at WhMgr.Extensions.JsonExtensions.FromJson[T](String json) in /home/whmgr/test/src/Extensions/JsonExtensions.cs:line 16
   at WhMgr.Services.Geofence.Geofence.FromJsonFile(String filePath) in /home/whmgr/test/src/Services/Geofence/Geofence.cs:line 110
   at WhMgr.Services.Geofence.Geofence.FromFile(String filePath) in /home/whmgr/test/src/Services/Geofence/Geofence.cs:line 100
   at WhMgr.Configuration.Config.LoadGeofences(Dictionary`2 servers) in /home/whmgr/test/src/Configuration/Config.cs:line 222
ChannelAlarms::LoadAlarms [ForGuildId=XXXXXX, AlarmsFilePath=alarms.json]
Alarms file /home/whmgr/test/bin/../bin/alarms/alarms.json was loaded successfully.
Could not find Geofence file "CITY" for alarm "REGION-100IV"
versx commented 2 years ago

This should be fixed in latest push now.

clburlison commented 2 years ago

Confirmed this has fixed