我在sql server中有一个具有地理类型的表。我使用实体框架和EntitySetController返回包含地理列的实体的[可查询]列表。
以下是返回数据的示例:
{
"d":{
"__count":"19534",
"results":[
{
"__metadata":{
"id":"http://localhost:2663/odata/Airports(1)",
"uri":"http://localhost:2663/odata/Airports(1)",
"type":"AirportDB.Airport"
},
"Id":1,
"SiteNumber":"50009.*A",
"Abbrev":"ADK",
"Name":"Adak",
"Type":"AIRPORT",
"GeoLocation":{
"__metadata":{
"type":"System.Data.Spatial.DbGeography"
},
"WellKnownValue":{
"__metadata":{
"type":"System.Data.Spatial.DbGeographyWellKnownValue"
},
"CoordinateSystemId":4326,
"WellKnownText":"POINT (-176.646 51.878)",
"WellKnownBinary":null
}
},
"LocationID":"'ADK",
"EffectiveDate":"\/Date(1367452800000)\/",
"Region":"AAL",
"DistrictOffice":"NONE",
"State":"AK",
"StateName":"ALASKA",
"County":"ALEUTIAN ISLANDS",
"CountyState":"AK",
"City":"ADAK ISLAND",
"FacilityName":"ADAK",
"Ownership":"PU",
"Use":"PU",
"Owner":"STATE OF ALASKA-DOTPF-CENTRAL RGN",
"OwnerAddress":"P O BOX 196900",
"OwnerCSZ":"\"ANCHORAGE, AK 99519\"",
"OwnerPhone":" 907-269-0751",
"Manager":"VINCE TUTIAKOFF",
"ManagerAddress":"P O BOX 1952",
"ManagerCSZ":"\"ADAK, AK 99546\"",
"ManagerPhone":" 907-592-8026",
"Latitude":51.877963888888893,
"Longitude":-176.64603055555554,
"ARPLatitude":"51-52-40.6700N",
"ARPLatitudeS":"186760.6700N",
"ARPLongitude":"176-38-45.7100W",
"ARPLongitudeS":"635925.7100W",
"ARPMethod":"E",
"ARPElevation":18,
"ARPElevationMethod":"S",
"MagneticVariation":"07E",
"MagneticVariationYear":2000,
"TrafficPatternAltitude":0,
"ChartName":"W ALEUTIAN ISLS",
"DistanceFromCBD":0,
"DirectionFromCBD":"W",
"LandAreaCoveredByAirport":0,
"BoundaryARTCCID":"ZAN",
"BoundaryARTCCComputerID":"ZAN",
"BoundaryARTCCName":"ANCHORAGE",
"ResponsibleARTCCID":"ZAP",
"ResponsibleARTCCComputerID":"ZAP",
"ResponsibleARTCCName":"ANCHORAGE OCEANIC",
"TieInFSS":"N",
"TieInFSSID":"CDB",
"TieInFSSName":"COLD BAY",
"AirportToFSSPhoneNumber":"907-532-2466",
"TieInFSSTollFreeNumber":"1-800-478-7250",
"AlternateFSSID":"ENA",
"AlternateFSSName":"KENAI",
"AlternateFSSTollFreeNumber":"1-866-864-1737",
"NOTAMFacilityID":"ADK",
"NOTAMService":"Y",
"ActiviationDate":"\/Date(-654912000000)\/",
"AirportStatusCode":"O",
"CertificationTypeDate":"I A S 04/2005",
"FederalAgreements":"N",
"AirspaceDetermination":"NO OBJECTION",
"CustomsAirportOfEntry":"N",
"CustomsLandingRights":"N",
"MilitaryJointUse":"N",
"MilitaryLandingRights":"Y",
"InspectionMethod":"F",
"InspectionGroup":"F",
"LastInspectionDate":9202012,
"LastOwnerInformationDate":1081991,
"FuelTypes":"A1",
"AirframeRepair":"NONE",
"PowerPlantRepair":"NONE",
"BottledOxygenType":"NONE",
"BulkOxygenType":"NONE",
"LightingSchedule":"SEE RMK",
"BeaconSchedule":"SS-SR",
"ATCT":"N",
"UNICOMFrequencies":0,
"CTAFFrequency":122.9,
"SegmentedCircle":"Y",
"BeaconColor":"CG",
"NonCommercialLandingFee":"",
"MedicalUse":"",
"SingleEngineGA":0,
"MultiEngineGA":0,
"JetEngineGA":0,
"HelicoptersGA":0,
"GlidersOperational":0,
"MilitaryOperational":0,
"Ultralights":0,
"OperationsCommercial":212,
"OperationsCommuter":0,
"OperationsAirTaxi":0,
"OperationsGALocal":0,
"OperationsGAItin":100,
"OperationsMilitary":28,
"OperationsDate":"\/Date(1325376000000)\/",
"AirportPositionSource":"",
"AirportPositionSourceDate":"",
"AirportElevationSource":"",
"AirportElevationSourceDate":"",
"ContractFuelAvailable":"",
"TransientStorage":"HGR",
"OtherServices":"CARGO",
"WindIndicator":"Y"
}
]
}
}
Jaydata在工厂配置模式下抛出异常:“无法解析类型:System.Data.Spatial.DbGeography”。
我做错了什么?如何以他们喜欢的方式将地理列返回到jaydata?
由于
修改
class Program
{
static void Main(string[] args)
{
var db = new AirportDB.mydatabaseService(new Uri("https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/"));
var airport = new Airport.Airport();
airport.Abbrev = "Foo";
airport.Name = "Bar";
airport.GeoLocation = GeographyPoint.Create(51.8779638888889, -176.646030555556);
db.AddToAirport(airport);
db.SaveChanges();
}
}
答案 0 :(得分:0)
对于Geo类型,我们使用GeoJSON。您可以执行以下操作: 假设您有一个具有以下结构的EntitySet:
point:
id: int,
point: $data.GeographyPoint
当您检索点数时使用地图(投影):
context.points.map(function(p) { return { id: id, point: { lat: Latitude, lng: Longitude } }, {}, "default")
请告知我们是否适合您
答案 1 :(得分:0)
您的服务终端必须公开OData standard format中的地理位置 - 通过检查J ayData Geo examples可以找到示例响应。
您有几个选项可以执行此操作: 1.带有WebAPI OData扩展的ASP.NET WebAPI
<强>型号:强>
public class Place
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public System.Spatial.GeographyPoint Location { get; set; }
}
<强>控制器:强>
[Queryable(AllowedQueryOptions=AllowedQueryOptions.All)]
public IQueryable<Place> Get()
{
data = new List<Place>();
data.Add(new Place() { Id = 0, Name = "Place1", Description = "Desc", Location = GeographyPoint.Create(-1.56, 29.76) });
data.Add(new Place() { Id = 1, Name = "Place1", Description = "Desc", Location = GeographyPoint.Create(-2.56, 19.76) });
return data.AsQueryable();
}
据我所知,实体框架在此类型方面存在一些问题,但可能会有所改善。
您可以在nodejs上使用odata-server npm模块,这是服务器端JayData和有用的帮助程序。您可以公开这些点,geo.distance()和geo.intersects()仅适用于JayData MongoDB Provider Pro。
您可以免费将您的积分保存到JayStorm PaaS Open Edition,并通过点击点击添加地理点字段来构建您自己的架构。