@@ -3,21 +3,22 @@ | |||
<PropertyGroup> | |||
<TargetFramework>net5.0</TargetFramework> | |||
<AssemblyVersion>1.0.1</AssemblyVersion> | |||
<UserSecretsId>2a42ef2e-4572-418c-b59d-bf2486f32108</UserSecretsId> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="AntDesign" Version="0.4.1" /> | |||
<PackageReference Include="AntDesign" Version="0.7.3" /> | |||
<PackageReference Include="JT1078" Version="1.1.0" /> | |||
<PackageReference Include="JT808" Version="2.3.4" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JT1078" Version="2.3.4" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JTActiveSafety" Version="1.1.3" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.Streamax" Version="0.2.0" /> | |||
<PackageReference Include="JT808" Version="2.3.7" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JT1078" Version="2.3.6" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JTActiveSafety" Version="1.1.5" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.Streamax" Version="0.2.3" /> | |||
<PackageReference Include="JT809" Version="2.2.0" /> | |||
<PackageReference Include="JT809.Protocol.Extensions.JT1078" Version="2.2.0" /> | |||
<PackageReference Include="JTActiveSafety" Version="1.0.0" /> | |||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> | |||
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" /> | |||
<PackageReference Include="JTActiveSafety" Version="1.0.1" /> | |||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.4" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.2" /> | |||
</ItemGroup> | |||
</Project> |
@@ -6,6 +6,7 @@ | |||
<Text> | |||
<Badge Color="red" />支持锐明808公交业务扩展协议<br /> | |||
<Badge Color="red" />支持主动安全附件(苏标)分析工具<br /> | |||
<Badge Color="red" />增加808分包解析 | |||
<Badge Color="red" />增加808分包解析<br /> | |||
<Badge Color="red" />增加地图-经纬度解析 | |||
</Text> | |||
</Paragraph> |
@@ -14,9 +14,11 @@ | |||
@using System.ComponentModel.DataAnnotations; | |||
@using System.Text.Json; | |||
<Select DefaultValue="@MsgType" @bind-Value="@MsgType" Style="width:200px" OnChange="@OnSelectMsgType"> | |||
<SelectOption Value="0x9101">808_打开看视频</SelectOption> | |||
<SelectOption Value="0x9102">808_关闭看视频</SelectOption> | |||
<Select DefaultValue="@MsgType" TItemValue="string" TItem="string" @bind-Value="@MsgType" Style="width:200px" OnSelectedItemChanged="OnSelectMsgType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0x9101")" Label="808_打开看视频" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0x9102")" Label="808_关闭看视频"/> | |||
</SelectOptions> | |||
</Select> | |||
@if (MsgType == "0x9101") | |||
@@ -40,17 +42,21 @@ | |||
<AntDesign.Input @bind-Value="@context.LogicalChannelNo" AllowClear> | |||
<AddOnBefore>通道号</AddOnBefore> | |||
</AntDesign.Input> | |||
<Select Style="width:150px;" DefaultValue="@context.DataType" @bind-Value="@context.DataType"> | |||
<SelectOption Value="0">音视频</SelectOption> | |||
<SelectOption Value="1">视频</SelectOption> | |||
<SelectOption Value="2">双向对讲</SelectOption> | |||
<SelectOption Value="3">监听</SelectOption> | |||
<SelectOption Value="4">中心广播</SelectOption> | |||
<SelectOption Value="5">透传</SelectOption> | |||
<Select Style="width:150px;" TItemValue="string" TItem="string" DefaultValue="@context.DataType" @bind-Value="@context.DataType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0")" Label="音视频"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("1")" Label="视频"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("2")" Label="双向对讲"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("3")" Label="监听"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("4")" Label="中心广播"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("5")" Label="透传"/> | |||
</SelectOptions> | |||
</Select> | |||
<Select Style="width:150px;" DefaultValue="@context.StreamType" @bind-Value="@context.StreamType"> | |||
<SelectOption Value="0">主码流</SelectOption> | |||
<SelectOption Value="1">子码流</SelectOption> | |||
<Select Style="width:150px;" TItemValue="string" TItem="string" DefaultValue="@context.StreamType" @bind-Value="@context.StreamType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0")" Label="主码流" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("1")" Label="子码流" /> | |||
</SelectOptions> | |||
</Select> | |||
<FormItem> | |||
<Button Type="primary" @onclick="@Pack">组包</Button> | |||
@@ -69,21 +75,27 @@ else if (MsgType == "0x9102") | |||
<AntDesign.Input @bind-Value="@context.LogicalChannelNo" AllowClear> | |||
<AddOnBefore>通道号</AddOnBefore> | |||
</AntDesign.Input> | |||
<Select Style="width:350px;" DefaultValue="@context.ControlCmd" @bind-Value="@context.ControlCmd"> | |||
<SelectOption Value="0">关闭音视频传输指令</SelectOption> | |||
<SelectOption Value="1">切换码流(增加暂停和继续)</SelectOption> | |||
<SelectOption Value="2">暂停该通道所有流的发送</SelectOption> | |||
<SelectOption Value="3">恢复暂停前流的发送,与暂停前的流类型一致</SelectOption> | |||
<SelectOption Value="4">关闭双向对讲</SelectOption> | |||
<Select Style="width:350px;" TItemValue="string" TItem="string" @bind-Value="@context.ControlCmd"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0")" Label="关闭音视频传输指令" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("1")" Label="切换码流(增加暂停和继续)" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("2")" Label="暂停该通道所有流的发送" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("3")" Label="恢复暂停前流的发送,与暂停前的流类型一致" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("4")" Label="关闭双向对讲" /> | |||
</SelectOptions> | |||
</Select> | |||
<Select Style="width:350px;" DefaultValue="@context.CloseAVData" @bind-Value="@context.CloseAVData"> | |||
<SelectOption Value="0">关闭该通道有关的音视频数据</SelectOption> | |||
<SelectOption Value="1">只关闭该通道有关的音频,保留该通道有关的视频</SelectOption> | |||
<SelectOption Value="2">只关闭该通道有关的视频,保留该通道有关的音频</SelectOption> | |||
<Select Style="width:350px;" TItemValue="string" TItem="string" @bind-Value="@context.CloseAVData"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0")" Label="关闭该通道有关的音视频数据" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("1")" Label="只关闭该通道有关的音频,保留该通道有关的视频" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("2")" Label="只关闭该通道有关的视频,保留该通道有关的音频" /> | |||
</SelectOptions> | |||
</Select> | |||
<Select Style="width:150px;" DefaultValue="@context.SwitchStreamType" @bind-Value="@context.SwitchStreamType"> | |||
<SelectOption Value="0">主码流</SelectOption> | |||
<SelectOption Value="1">子码流</SelectOption> | |||
<Select Style="width:150px;" TItemValue="string" TItem="string" @bind-Value="@context.SwitchStreamType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("0")" Label="主码流" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("1")" Label="子码流" /> | |||
</SelectOptions> | |||
</Select> | |||
<FormItem> | |||
<Button Type="primary" @onclick="@Pack">组包</Button> | |||
@@ -110,12 +122,14 @@ else if (MsgType == "0x9102") | |||
JT1078Serializer = jT808_JT1078_Config.GetSerializer(); | |||
} | |||
void OnSelectMsgType(OneOf<string, IEnumerable<string>, LabeledValue, IEnumerable<LabeledValue>> value, | |||
OneOf<SelectOption, IEnumerable<SelectOption>> option) | |||
void OnSelectMsgType(string value) | |||
{ | |||
MsgType = value.Value.ToString(); | |||
MsgType = value; | |||
} | |||
void Pack() | |||
{ | |||
try | |||
@@ -129,10 +143,10 @@ else if (MsgType == "0x9102") | |||
header.TerminalPhoneNo = jT_0X9101_Form.Sim; | |||
jT808Package.Header = header; | |||
JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); | |||
jT808_0X9101.ServerIPAddress = jT_0X9101_Form.IPAddress; | |||
jT808_0X9101.ServerVideoChannelTcpPort = (ushort)jT_0X9101_Form.TcpPort; | |||
jT808_0X9101.ServerVideoChannelUdpPort = (ushort)jT_0X9101_Form.UdpPort; | |||
jT808_0X9101.LogicalChannelNo = jT_0X9101_Form.LogicalChannelNo; | |||
jT808_0X9101.ServerIp = jT_0X9101_Form.IPAddress; | |||
jT808_0X9101.TcpPort = (ushort)jT_0X9101_Form.TcpPort; | |||
jT808_0X9101.UdpPort = (ushort)jT_0X9101_Form.UdpPort; | |||
jT808_0X9101.ChannelNo = jT_0X9101_Form.LogicalChannelNo; | |||
jT808_0X9101.DataType = byte.Parse(jT_0X9101_Form.DataType); | |||
jT808_0X9101.StreamType = byte.Parse(jT_0X9101_Form.StreamType); | |||
jT808Package.Bodies = jT808_0X9101; | |||
@@ -147,10 +161,10 @@ else if (MsgType == "0x9102") | |||
header.TerminalPhoneNo = jT_0x9102_Form.Sim; | |||
jT808Package.Header = header; | |||
JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); | |||
jT808_0X9102.LogicalChannelNo = jT_0x9102_Form.LogicalChannelNo; | |||
jT808_0X9102.ChannelNo = jT_0x9102_Form.LogicalChannelNo; | |||
jT808_0X9102.ControlCmd = byte.Parse(jT_0x9102_Form.ControlCmd); | |||
jT808_0X9102.CloseAVData = byte.Parse(jT_0x9102_Form.CloseAVData); | |||
jT808_0X9102.SwitchStreamType = byte.Parse(jT_0x9102_Form.SwitchStreamType); | |||
jT808_0X9102.StreamType = byte.Parse(jT_0x9102_Form.SwitchStreamType); | |||
jT808Package.Bodies = jT808_0X9102; | |||
HexData = JT1078Serializer.Serialize(jT808Package).ToHexString(); | |||
} | |||
@@ -4,11 +4,13 @@ | |||
@using JT808.Protocol.Extensions; | |||
@using JTTools.Configs; | |||
@inject IJT808Config Config | |||
@using OneOf; | |||
<Select DefaultValue=@wayType @bind-Value="@wayType" Style="width:100px" OnChange="@OnSelectWayType"> | |||
<SelectOption Value="up">上行</SelectOption> | |||
<SelectOption Value="down">下行</SelectOption> | |||
<Select @bind-Value="@wayType" TItemValue="string" TItem="string" Style="width:100px" OnSelectedItemChanged="@OnSelectWayType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("up")" Label="上行"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("down")" Label="下行"/> | |||
</SelectOptions> | |||
</Select> | |||
<Button Type="primary" @onclick="Query">分析</Button> | |||
@@ -35,10 +37,9 @@ | |||
string wayType = "up"; | |||
private void OnSelectWayType(OneOf<string, IEnumerable<string>, LabeledValue, IEnumerable<LabeledValue>> value, | |||
OneOf<SelectOption, IEnumerable<SelectOption>> option) | |||
private void OnSelectWayType(string value) | |||
{ | |||
wayType = value.Value.ToString(); | |||
wayType = value; | |||
switch (wayType) | |||
{ | |||
case "up": | |||
@@ -14,11 +14,13 @@ | |||
@using OneOf; | |||
<Tag Color="blue">如有分包,请换行区分。</Tag><br /> | |||
<Select DefaultValue="@protocolType" @bind-Value="@protocolType" Style="width:200px" OnChange="@OnSelectProtocolType"> | |||
<SelectOption Value="JT808">国标</SelectOption> | |||
<SelectOption Value="JT808_JT1078">国标扩展JT1078</SelectOption> | |||
<SelectOption Value="JT808_JTAS">国标扩展主动安全(苏标)</SelectOption> | |||
<SelectOption Value="JT808_JTRM">公交扩展协议(锐明)</SelectOption> | |||
<Select TItemValue="string" TItem="string" @bind-Value="@protocolType" Style="width:200px" OnSelectedItemChanged="OnSelectProtocolType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Label="国标" Value="@("JT808")" /> | |||
<SelectOption TItemValue="string" TItem="string" Label="国标扩展JT1078" Value="@("JT808_JT1078")" /> | |||
<SelectOption TItemValue="string" TItem="string" Label="国标扩展主动安全(苏标)" Value="@("JT808_JTAS")" /> | |||
<SelectOption TItemValue="string" TItem="string" Label="公交扩展协议(锐明)" Value="@("JT808_JTRM")" /> | |||
</SelectOptions> | |||
</Select> | |||
<Button Type="primary" @onclick="Query">分析</Button> | |||
@@ -63,8 +65,7 @@ | |||
isOpen = !isOpen; | |||
} | |||
private void OnSelectProtocolType(OneOf<string, IEnumerable<string>, LabeledValue, IEnumerable<LabeledValue>> value, | |||
OneOf<SelectOption, IEnumerable<SelectOption>> option) | |||
private void OnSelectProtocolType(string value) | |||
{ | |||
if ("JT808_JT1078" == protocolType) | |||
{ | |||
@@ -74,8 +75,8 @@ | |||
{ | |||
HexData = HexDataTmp; | |||
} | |||
protocolType = value.Value.ToString(); | |||
StateHasChanged(); | |||
protocolType = value; | |||
//StateHasChanged(); | |||
} | |||
private void OnAreaTextPressEnter(KeyboardEventArgs eventArgs) | |||
@@ -13,14 +13,18 @@ | |||
@inject JT809_2011_Config Config2011 | |||
@inject JT809_2019_Config Config2019 | |||
<Select DefaultValue="@version" @bind-Value="@version" Style="width:200px" OnChange="@OnSelectVersion"> | |||
<SelectOption Value="v2011">2011版本</SelectOption> | |||
<SelectOption Value="v2019">2019版本</SelectOption> | |||
<Select @bind-Value="@version" TItemValue="string" TItem="string" Style="width:200px" OnSelectedItemChanged="OnSelectVersion"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("v2011")" Label="2011版本"/> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("v2019")" Label="2019版本"/> | |||
</SelectOptions> | |||
</Select> | |||
<Select DefaultValue="@encryptType" @bind-Value="@encryptType" Style="width:200px" OnChange="@OnSelectEncryptType"> | |||
<SelectOption Value="none">未加密</SelectOption> | |||
<SelectOption Value="encrypt">加密</SelectOption> | |||
<Select TItemValue="string" TItem="string" @bind-Value="@encryptType" Style="width:200px" OnSelectedItemChanged="OnSelectEncryptType"> | |||
<SelectOptions> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("none")" Label="未加密" /> | |||
<SelectOption TItemValue="string" TItem="string" Value="@("encrypt")" Label="加密" /> | |||
</SelectOptions> | |||
</Select> | |||
@if (encryptType == "encrypt") | |||
@@ -81,10 +85,9 @@ | |||
isOpen = !isOpen; | |||
} | |||
public void OnSelectVersion(OneOf<string, IEnumerable<string>, LabeledValue, IEnumerable<LabeledValue>> value, | |||
OneOf<SelectOption, IEnumerable<SelectOption>> option) | |||
public void OnSelectVersion(string value) | |||
{ | |||
this.version = value.Value.ToString(); | |||
this.version = value; | |||
switch (version) | |||
{ | |||
case "v2011": | |||
@@ -97,10 +100,9 @@ | |||
StateHasChanged(); | |||
} | |||
private void OnSelectEncryptType(OneOf<string, IEnumerable<string>, LabeledValue, IEnumerable<LabeledValue>> value, | |||
OneOf<SelectOption, IEnumerable<SelectOption>> option) | |||
private void OnSelectEncryptType(string value) | |||
{ | |||
encryptType = value.Value.ToString(); | |||
encryptType = value; | |||
StateHasChanged(); | |||
} | |||
@@ -0,0 +1,127 @@ | |||
@page "/map" | |||
@using System.Text; | |||
@using System.Text.Encodings.Web; | |||
@using System.Text.Unicode; | |||
@using System.ComponentModel.DataAnnotations; | |||
@using System.Text.Json; | |||
@inject IJSRuntime JsRuntime | |||
<RadioGroup @bind-Value="coordinateType" Size="large" TValue="string" OnChange="@OnSelectedCoordinateTypeChanged"> | |||
<Radio RadioButton Value="@("WGS84")">WGS84</Radio> | |||
<Radio RadioButton Value="@("GCJ02")">GCJ02</Radio> | |||
<Radio RadioButton Value="@("BD09")">BD09</Radio> | |||
</RadioGroup> | |||
<br /> | |||
<AntDesign.Input @bind-Value="LngLat" style="width: 450px;" Size="large" AllowClear> | |||
<AddOnBefore>经纬度</AddOnBefore> | |||
</AntDesign.Input> | |||
<Button Type="primary" @onclick="Convert" Size="large"> | |||
转换 | |||
</Button> | |||
<Button Type="primary" @onclick="CreateMarker" Size="large"> | |||
创建标注点 | |||
</Button> | |||
<br /> | |||
<AntDesign.Input @bind-Value="WGS84_LngLat" style="width: 450px;" Size="large" readonly> | |||
<AddOnBefore>WGS84坐标系</AddOnBefore> | |||
</AntDesign.Input> | |||
<br /> | |||
<AntDesign.Input @bind-Value="GCJ02_LngLat" style="width: 450px;" Size="large" readonly> | |||
<AddOnBefore>GCJ02坐标系</AddOnBefore> | |||
</AntDesign.Input> | |||
<br /> | |||
<AntDesign.Input @bind-Value="BD09_LngLat" style="width: 450px;" Size="large" readonly> | |||
<AddOnBefore>BD09坐标系</AddOnBefore> | |||
</AntDesign.Input> | |||
<br /> | |||
@if (isOpen) | |||
{ | |||
<Alert Type="@AlertType.Error" Description="@ErrerMessage" Closable AfterClose="OnDismiss" /> | |||
<br /> | |||
} | |||
<div id="mapContainer" style="width: 1024px; height: 768px; "></div> | |||
@code { | |||
string coordinateType = "GCJ02"; | |||
private string LngLat= "113.87132,22.568962"; | |||
private string WGS84_LngLat; | |||
private string GCJ02_LngLat; | |||
private string BD09_LngLat; | |||
private string ErrerMessage; | |||
private bool isOpen = false; | |||
protected override async void OnInitialized() | |||
{ | |||
await JsRuntime.InvokeVoidAsync("mapInit"); | |||
} | |||
void OnDismiss() | |||
{ | |||
isOpen = !isOpen; | |||
} | |||
void OnSelectedCoordinateTypeChanged(string e) | |||
{ | |||
if (string.IsNullOrEmpty(LngLat)) | |||
{ | |||
return; | |||
} | |||
string[] arr = LngLat.Split(new string[]{ ",", ",", "|", ":" }, StringSplitOptions.RemoveEmptyEntries); | |||
if (arr.Length == 2) | |||
{ | |||
if(double.TryParse(arr[0], out double lng) && double.TryParse(arr[1], out double lat)) | |||
{ | |||
if(e== "WGS84") | |||
{ | |||
WGS84_LngLat = $"{lng},{lat}"; | |||
var gcj02 = Coordtransform.Wgs84togcj02(lng, lat); | |||
GCJ02_LngLat = $"{gcj02[0]},{gcj02[1]}"; | |||
var bd09 = Coordtransform.Wgs84tobd09(lng, lat); | |||
BD09_LngLat = $"{bd09[0]},{bd09[1]}"; | |||
} | |||
else if (e == "GCJ02") | |||
{ | |||
GCJ02_LngLat = $"{lng},{lat}"; | |||
var wgs84 = Coordtransform.Gcj02towgs84(lng, lat); | |||
WGS84_LngLat = $"{wgs84[0]},{wgs84[1]}"; | |||
var bd09 = Coordtransform.Gcj02tobd09(lng, lat); | |||
BD09_LngLat = $"{bd09[0]},{bd09[1]}"; | |||
} | |||
else if (e == "BD09") | |||
{ | |||
BD09_LngLat = $"{lng},{lat}"; | |||
var wgs84 = Coordtransform.Bd09towgs84(lng, lat); | |||
WGS84_LngLat = $"{wgs84[0]},{wgs84[1]}"; | |||
var gcj02 = Coordtransform.Bd09togcj02(lng, lat); | |||
GCJ02_LngLat = $"{gcj02[0]},{gcj02[1]}"; | |||
} | |||
} | |||
} | |||
} | |||
[JSInvokable] | |||
public void Convert() | |||
{ | |||
OnSelectedCoordinateTypeChanged(coordinateType); | |||
} | |||
[JSInvokable] | |||
public async void CreateMarker() | |||
{ | |||
if (string.IsNullOrEmpty(GCJ02_LngLat)) | |||
{ | |||
return; | |||
} | |||
string[] arr = GCJ02_LngLat.Split(',', StringSplitOptions.RemoveEmptyEntries); | |||
await JsRuntime.InvokeVoidAsync("createMarker", arr); | |||
} | |||
} |
@@ -16,12 +16,17 @@ | |||
<base href="~/" /> | |||
<link rel="icon" href="logo.png" type="image/x-icon"> | |||
<link href="_content/AntDesign/css/ant-design-blazor.css" rel="stylesheet"> | |||
<script type="text/javascript" src='//webapi.amap.com/maps?v=1.4.15&key=1beaad9c96973cf1614ab8703cb60356&plugin=AMap.MouseTool'> | |||
</script> | |||
<!-- UI组件库 1.0 --> | |||
<script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script> | |||
</head> | |||
<body> | |||
<app> | |||
<component type="typeof(App)" render-mode="Server" /> | |||
</app> | |||
<script src="_content/AntDesign/js/ant-design-blazor.js"></script> | |||
<script src="~/js/map.js"></script> | |||
<script src="_framework/blazor.server.js"></script> | |||
</body> | |||
@@ -17,8 +17,11 @@ | |||
</MenuItem> | |||
<MenuItem Key="jt19056" RouterLink="jt19056"> | |||
<span class="nav-text">JT19056分析工具</span> | |||
</MenuItem> | |||
</MenuItem> | |||
<MenuItem Key="jtas" RouterLink="jtas"> | |||
<span class="nav-text">JTActiveSafety分析工具</span> | |||
</MenuItem> | |||
<MenuItem Key="map" RouterLink="map"> | |||
<span class="nav-text">地图-经纬度解析</span> | |||
</MenuItem> | |||
</Menu> |
@@ -0,0 +1,237 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
namespace JTTools | |||
{ | |||
public class Coordtransform | |||
{ | |||
//定义一些常量 | |||
private const double x_PI = 3.14159265358979324 * 3000.0 / 180.0; | |||
private const double PI = 3.1415926535897932384626;// π | |||
private const double a = 6378245.0;// 长半轴 | |||
private const double ee = 0.00669342162296594323;// 偏心率平方 | |||
/// <summary> | |||
/// 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换 | |||
/// 即 百度 转 谷歌、高德 | |||
/// </summary> | |||
/// <param name="bd_lon"></param> | |||
/// <param name="bd_lat"></param> | |||
/// <returns></returns> | |||
public static double[] Bd09togcj02(double bd_lon, double bd_lat) | |||
{ | |||
double x = bd_lon - 0.0065; | |||
double y = bd_lat - 0.006; | |||
double z = Math.Sqrt(x * x + y * y) - 0.00002 * Math.Sin(y * x_PI); | |||
double theta = Math.Atan2(y, x) - 0.000003 * Math.Cos(x * x_PI); | |||
double gg_lng = z * Math.Cos(theta); | |||
double gg_lat = z * Math.Sin(theta); | |||
return new[] { gg_lng, gg_lat }; | |||
} | |||
/// <summary> | |||
/// 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换 | |||
/// 即谷歌、高德 转 百度 | |||
/// </summary> | |||
/// <param name="lng"></param> | |||
/// <param name="lat"></param> | |||
/// <returns></returns> | |||
public static double[] Gcj02tobd09(double lng, double lat) | |||
{ | |||
double z = Math.Sqrt(lng * lng + lat * lat) + 0.00002 * Math.Sin(lat * x_PI); | |||
double theta = Math.Atan2(lat, lng) + 0.000003 * Math.Cos(lng * x_PI); | |||
double bd_lng = z * Math.Cos(theta) + 0.0065; | |||
double bd_lat = z * Math.Sin(theta) + 0.006; | |||
return new[] { bd_lng, bd_lat }; | |||
} | |||
/// <summary> | |||
/// WGS84转GCj02 | |||
/// </summary> | |||
/// <param name="lng"></param> | |||
/// <param name="lat"></param> | |||
/// <returns></returns> | |||
public static double[] Wgs84togcj02(double lng, double lat) | |||
{ | |||
if (Out_of_china(lng, lat)) | |||
{ | |||
return new[] { lng, lat }; | |||
} | |||
else | |||
{ | |||
double dlat = Transformlat(lng - 105.0, lat - 35.0); | |||
double dlng = Transformlng(lng - 105.0, lat - 35.0); | |||
double radlat = lat / 180.0 * PI; | |||
double magic = Math.Sin(radlat); | |||
magic = 1 - ee * magic * magic; | |||
double sqrtmagic = Math.Sqrt(magic); | |||
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); | |||
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.Cos(radlat) * PI); | |||
double mglat = lat + dlat; | |||
double mglng = lng + dlng; | |||
return new[] { mglng, mglat }; | |||
} | |||
} | |||
/// <summary> | |||
/// 批量WGS84转GCj02 | |||
/// </summary> | |||
/// <param name="wgs84s">[[lng,lat],...]</param> | |||
/// <returns></returns> | |||
public static List<double[]> Wgs84togcj02(List<double[]> wgs84s) | |||
{ | |||
List<double[]> gcj02s = new List<double[]>(); | |||
foreach (var wgs84 in wgs84s) | |||
{ | |||
var lng = wgs84[0]; | |||
var lat = wgs84[1]; | |||
if (Out_of_china(lng, lat)) | |||
{ | |||
gcj02s.Add( new[] { lng, lat }); | |||
} | |||
else | |||
{ | |||
double dlat = Transformlat(lng - 105.0, lat - 35.0); | |||
double dlng = Transformlng(lng - 105.0, lat - 35.0); | |||
double radlat = lat / 180.0 * PI; | |||
double magic = Math.Sin(radlat); | |||
magic = 1 - ee * magic * magic; | |||
double sqrtmagic = Math.Sqrt(magic); | |||
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); | |||
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.Cos(radlat) * PI); | |||
double mglat = lat + dlat; | |||
double mglng = lng + dlng; | |||
gcj02s.Add( new[] { mglng, mglat }); | |||
} | |||
} | |||
return gcj02s; | |||
} | |||
/// <summary> | |||
/// GCJ02 转换为 WGS84 | |||
/// </summary> | |||
/// <param name="lng"></param> | |||
/// <param name="lat"></param> | |||
/// <returns></returns> | |||
public static double[] Gcj02towgs84(double lng, double lat) | |||
{ | |||
if (Out_of_china(lng, lat)) | |||
{ | |||
return new[] { lng, lat }; | |||
} | |||
else | |||
{ | |||
double dlat = Transformlat(lng - 105.0, lat - 35.0); | |||
double dlng = Transformlng(lng - 105.0, lat - 35.0); | |||
double radlat = lat / 180.0 * PI; | |||
double magic = Math.Sin(radlat); | |||
magic = 1 - ee * magic * magic; | |||
double sqrtmagic = Math.Sqrt(magic); | |||
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); | |||
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.Cos(radlat) * PI); | |||
double mglat = lat + dlat; | |||
double mglng = lng + dlng; | |||
return new[] { lng * 2 - mglng, lat * 2 - mglat }; | |||
} | |||
} | |||
/// <summary> | |||
/// 批量GCJ02 转换为 WGS84 | |||
/// </summary> | |||
/// <param name="gcj02s">[[lng,lat],...]</param> | |||
/// <returns></returns> | |||
public static List<double[]> Gcj02towgs84(List<double[]> gcj02s) | |||
{ | |||
List<double[]> wgs84s = new List<double[]>(); | |||
foreach (var gcj02 in gcj02s) | |||
{ | |||
var lng = gcj02[0]; | |||
var lat = gcj02[1]; | |||
if (Out_of_china(lng, lat)) | |||
{ | |||
wgs84s.Add(new[] { lng, lat }); | |||
} | |||
else | |||
{ | |||
double dlat = Transformlat(lng - 105.0, lat - 35.0); | |||
double dlng = Transformlng(lng - 105.0, lat - 35.0); | |||
double radlat = lat / 180.0 * PI; | |||
double magic = Math.Sin(radlat); | |||
magic = 1 - ee * magic * magic; | |||
double sqrtmagic = Math.Sqrt(magic); | |||
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); | |||
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.Cos(radlat) * PI); | |||
double mglat = lat + dlat; | |||
double mglng = lng + dlng; | |||
wgs84s.Add(new[] { lng * 2 - mglng, lat * 2 - mglat }); | |||
} | |||
} | |||
return wgs84s; | |||
} | |||
public static double Transformlat(double lng, double lat) | |||
{ | |||
double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.Sqrt(Math.Abs(lng)); | |||
ret += (20.0 * Math.Sin(6.0 * lng * PI) + 20.0 * Math.Sin(2.0 * lng * PI)) * 2.0 / 3.0; | |||
ret += (20.0 * Math.Sin(lat * PI) + 40.0 * Math.Sin(lat / 3.0 * PI)) * 2.0 / 3.0; | |||
ret += (160.0 * Math.Sin(lat / 12.0 * PI) + 320 * Math.Sin(lat * PI / 30.0)) * 2.0 / 3.0; | |||
return ret; | |||
} | |||
public static double Transformlng(double lng, double lat) | |||
{ | |||
double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.Sqrt(Math.Abs(lng)); | |||
ret += (20.0 * Math.Sin(6.0 * lng * PI) + 20.0 * Math.Sin(2.0 * lng * PI)) * 2.0 / 3.0; | |||
ret += (20.0 * Math.Sin(lng * PI) + 40.0 * Math.Sin(lng / 3.0 * PI)) * 2.0 / 3.0; | |||
ret += (150.0 * Math.Sin(lng / 12.0 * PI) + 300.0 * Math.Sin(lng / 30.0 * PI)) * 2.0 / 3.0; | |||
return ret; | |||
} | |||
/// <summary> | |||
/// 判断是否在国内,不在国内则不做偏移 | |||
/// 纬度3.86~53.55,经度73.66~135.05 | |||
/// </summary> | |||
/// <param name="lng"></param> | |||
/// <param name="lat"></param> | |||
/// <returns></returns> | |||
public static bool Out_of_china(double lng, double lat) | |||
{ | |||
return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55); ; | |||
} | |||
/// <summary> | |||
/// WGS84坐标系->百度坐标系 | |||
/// </summary> | |||
/// <param name="lon"></param> | |||
/// <param name="lat"></param> | |||
/// <returns></returns> | |||
public static double[] Wgs84tobd09(double lon, double lat) | |||
{ | |||
var gcj02 = Wgs84togcj02(lon, lat); | |||
return Gcj02tobd09(gcj02[0], gcj02[1]); | |||
} | |||
/// <summary> | |||
/// 百度坐标系->WGS84坐标系 | |||
/// </summary> | |||
/// <param name="bd_lon"></param> | |||
/// <param name="bd_lat"></param> | |||
/// <returns></returns> | |||
public static double[] Bd09towgs84(double bd_lon, double bd_lat) | |||
{ | |||
var gcj02 = Bd09togcj02(bd_lon, bd_lat); | |||
return Gcj02towgs84(gcj02[0], gcj02[1]); | |||
} | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
function mapInit() { | |||
console.debug("mapinit"); | |||
//延迟加载下 | |||
setTimeout(() => { | |||
window.map = new AMap.Map('mapContainer', { | |||
zoom: 12, | |||
center: [114.085947, 22.547] | |||
}); | |||
}, 1500) | |||
} | |||
function createMarker(gcj02_lng,gcj02_lat) { | |||
console.debug("Marker", gcj02_lng, gcj02_lat); | |||
var marker = new AMap.Marker({ | |||
position: new AMap.LngLat(gcj02_lng, gcj02_lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9] | |||
icon: new AMap.Icon({ | |||
imageSize: new AMap.Size(36, 36), | |||
}) | |||
}); | |||
window.map.add(marker); | |||
window.map.setFitView(marker); | |||
} |