0

我在 sql server 中有一个地理类型的表。我使用实体框架和 EntitySetController 返回包​​含地理列的实体的 [Queryable] 列表。

以下是返回数据的示例:

{
        "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?

谢谢

编辑:

@robesz 根据您的 JayStorm Paas Open Edition 建议,我创建了一个帐户,创建了一个匹配的架构,创建了一个 .Net 控制台应用程序来添加一些数据,但它抱怨 GeoLocation 列中的格式无效。我该如何解决?此外,当我执行行 SaveChanges() 时,它首先抱怨需要 odata v3,但导入过程硬编码 V2,所以我手动编辑了生成的客户端存根(不理想) - 我将如何解决这个问题?而且,没有更简单的方法可以将数据导入 JayStorm 表吗?最后,我在哪里可以找到超过 100 万条记录的定价?

 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();

        }
    }
4

2 回答 2

0

对于地理类型,我们使用 GeoJSON。您可以执行以下操作:假设您有一个具有以下结构的 EntitySet:

 point:
    id: int,
    point: $data.GeographyPoint

当您检索点使用地图(投影)时:

 context.points.map(function(p) { return { id: id, point: { lat: Latitude, lng: Longitude } }, {}, "default")

请让我们知道它是否适合您

于 2013-06-14T08:16:40.243 回答
0

您的服务端点必须以OData 标准格式公开地理点- 可以通过检查JayData Geo 示例找到示例响应。

您有几个选项可以做到这一点: 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();
}

据我所知,Entity Framework 在这种类型方面存在一些问题,但可能已经有所改进。

  1. 您可以在 nodejs 上使用odata-server npm 模块,这是带有有用助手的服务器端 JayData。您可以公开这些点,geo.distance() 和 geo.intersects() 仅适用于 JayData MongoDB Provider Pro。

  2. 您可以免费将您的点保存到JayStorm PaaS 开放版,并通过点击构建您自己的模式 - 添加地理点字段。

于 2013-06-14T08:23:06.830 回答