细节调整
This commit is contained in:
parent
6d9acac89d
commit
61439bf419
|
|
@ -85,17 +85,22 @@ namespace LY.App.Service
|
||||||
{
|
{
|
||||||
var key = RedisKeyList.PositioinRegion(positionId);
|
var key = RedisKeyList.PositioinRegion(positionId);
|
||||||
var geodata = await _redisService.GetAsync<string>(key);
|
var geodata = await _redisService.GetAsync<string>(key);
|
||||||
|
if (geodata == null)
|
||||||
|
{
|
||||||
|
geodata = await _db.CopyNew().Queryable<PositionInfo>()
|
||||||
|
.Where(s => s.Id == positionId)
|
||||||
|
.Select(s => s.Region)
|
||||||
|
.FirstAsync();
|
||||||
|
await _redisService.SetAsync<string>(key, geodata);
|
||||||
|
}
|
||||||
WKTReader reader = new WKTReader();
|
WKTReader reader = new WKTReader();
|
||||||
Geometry point = reader.Read($"POINT ({lon} {lat})");
|
Geometry point = reader.Read($"POINT ({lon} {lat})");
|
||||||
if (!string.IsNullOrEmpty(geodata))
|
|
||||||
{
|
|
||||||
Geometry multipolygon = reader.Read(geodata);
|
Geometry multipolygon = reader.Read(geodata);
|
||||||
if (multipolygon.Contains(point))
|
if (multipolygon.Contains(point))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ namespace LY.App.Service
|
||||||
foreach (var item in position)
|
foreach (var item in position)
|
||||||
{
|
{
|
||||||
var key = RedisKeyList.PositioinRegion(item.Id);
|
var key = RedisKeyList.PositioinRegion(item.Id);
|
||||||
await _redisService.SetAsync(key, item.Region, TimeSpan.FromDays(100));
|
await _redisService.SetAsync(key, item.Region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue