public static NetTopologySuite.Geometries.Polygon GeometryJsonToPolygon(this SpatialDataObtain spatialDataObtain, IPolygon polygon)
        {
            string geometryJson = ESRIDataOpention.ConvertGeometryToJson(polygon);

            if (string.IsNullOrEmpty(geometryJson))
            {
                geometryJson = ESRIDataOpention.ConvertGeometryToJson(polygon, true);
            }
            return(SpatialDataObtain.GeometryJsonToPolygon(JObject.Parse(geometryJson)));
        }
예제 #2
0
        static void Main(string[] args)
        {
            object[] vs2              = new object[4];
            ConcurrentQueue <int> vs  = new ConcurrentQueue <int>();
            ConcurrentBag <int>   VS1 = new ConcurrentBag <int>();

            VS1.Add(1);
            VS1.Add(2);
            VS1.Add(3);
            VS1.Add(4);
            //vs.Prepend(1);
            //vs.Prepend(2);
            //vs.Prepend(3);
            //vs.Prepend(4);
            int i;

            VS1.TryTake(out i);
            Console.WriteLine(i);
            VS1.TryTake(out i);
            Console.WriteLine(i);
            VS1.TryTake(out i);
            Console.WriteLine(i);
            DistributedGIS.ESRI.Extensions.LicenseUtil.CheckOutLicenseAdvanced();
            TestJsonToPolygon();
            SpatialDataObtain spatialDataObtain = new SpatialDataObtain();

            spatialDataObtain.ServerDataToGDB("http://52.82.98.186:6080/arcgis/rest/services/YZT/YZTYLSJ/MapServer/31", "1=1", null, 1000);
            // SpatialDataObtain.ServerDataToGDB("http://52.82.98.186:6080/arcgis/rest/services/YZT/YZTYLSJ/MapServer/30", "1=1",null,10);
            Console.Read();
            RSA pubKeyRsaProvider = CreateRsaProviderFromPrivateKey("MIIEpQIBAAKCAQEAuVOrbikW3sddQCyNQR+CygA3Khp+ZyEE6S5lnUJS4u13S4ZT1Y578Ik9vO4dCSeNMLZaIGl8LgntHIDPHJy/YZdkTnF5/I3C7uKTsG2HbzcNHKlh16mqTNTKjCKbJ7IlLYbA3YbPb+UThQSKLwMJR10ONqSCOgahlRnR6fREZlG3yiNXd358T5njqsCgjhBcUyYmAcc5ae+a+bT0NvwAtlOiUkWtL5TMuB91RuZrkQIs68S8jIItKaQV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bXKC97biZ4o+6Lu/CONFFetBuptJAo5BTjHGW2nm0OrXjVvyZpYLCu3/hCvIoOsm48xAEKS9BonZBoECgYEAi1muApbZJYalb9rtVUNCs0CE8Zz5X4jIHJdCDPNHVxWqOR1bKDiKI84lEteDbZp5zAggImssIadYWd3klgFVo85pE58wG9a7+UlxFmzu+Di8jj4Y2LlQql5oE8xbpF5lwZrgGEhhYGtZUDuz0pES7fV5xydymyzctlR6BcqWMQ0=");
            //JcVRfx9irMiGMhGslc6Mz5mnwwrfRTJQjNgPpnPrnv9X6WJoTKCRO8rw2Ji+gAWfM9u00qyj474+ZzNTxrmbNHXHbV3xmULJreoOvMkdZY8NMErBpXPB3Mt7J0yxZVCmnrSsu5fhwNkK5N0WtofWz+lLHd3U7mLBdsyqtDsCWiSur+5tg5PpFLx51gj5l3J0YWklsmEXHKDEgqzzY3XXRYsV2O7zgV8kjVu8fwlBJSvtiMVEpuxFUTKiceqQWiHceQawMamQ4GZfSr4ubCShgZxwzw7IuER8lomRZ+i3D6uTb3PsQGqdwZ9PFt81nrhClMdmDtUmXuiL2jfyTTclTQ==
            string pas = "******";
            // Console.WriteLine(lD4CknpHHHZxk68PUHOUaKnPcac2t5mNay3Svjc0x4p2ZgBiU0kaSrUIxx7S1t0Ztc47KcbMl0A2NRdSBV74mG9QU42KKvBgBwPP / Eh4JQA4LLeVRxoDTf4T8FLyVyaKT / 7oy6XqC2NGlOOcrrJbUd9dETRiw ==);


            string tt = Encoding.UTF8.GetString(pubKeyRsaProvider.Decrypt(Convert.FromBase64String(pas), RSAEncryptionPadding.Pkcs1));

            Console.WriteLine(Convert.ToString(Convert.FromBase64String("JSCeBYsEQpy7RWttqGI/w0RbEMYqUjZpPNjARHDi2MEX9IjcKwiSeIeUbpL450qIbqnNHOgBHo5vJDvHXNACHTiUqc4TKXgrXlXCY8P3zknfxjIOuYlmkDXoXGj/1nxvp0aJoRgqLs33gtjH15JUtEyn0g2lp8ZkJQMrUhV6R/8vJrnlRg1G4uS7hlD4CknpHHHZxk68PUHOUaKnPcac2t5mNay3Svjc0x4p2ZgBiU0kaSrUIxx7S1t0Ztc47KcbMl0A2NRdSBV74mG9QU42KKvBgBwPP/Eh4JQA4LLeVRxoDTf4T8FLyVyaKT/7oy6XqC2NGlOOcrrJbUd9dETRiw==")));
            Console.WriteLine("Hello World!");
        }
예제 #3
0
 public static void TestJsonToPolygon()
 {
     string  json    = "{\"rings\":[[[120.32892328100002,30.800848293],[120.32892502300001,30.800707623999983],[120.32889502499995,30.800257430999977],[120.32888342199999,30.800148931000024],[120.32878373699998,30.799215616000026],[120.32880196300005,30.799185717],[120.32896307399994,30.79916738999998],[120.32923182000002,30.799116826999978],[120.32951267399994,30.799026718999983],[120.32969864999995,30.798947569000006],[120.32978478899997,30.79893698500001],[120.32978258100002,30.798936592000018],[120.329715093,30.798924562000025],[120.32889056299996,30.799135509999985],[120.32840741400003,30.79911301499999],[120.32841549299997,30.799058419999994],[120.32853243600005,30.799054857999977],[120.32830239600003,30.799056683999993],[120.32829125399996,30.799171742999988],[120.32853309699999,30.799179379999998],[120.32856622899999,30.799182807000022],[120.32857849200002,30.799217371999987],[120.328721008,30.800029229000017],[120.32872694499997,30.800148103000026],[120.32873394499995,30.80028998199998],[120.328734747,30.800675802],[120.32873499899995,30.80079732500002],[120.32872976399995,30.800820871999974],[120.32871909200003,30.800868664999996],[120.32871043600005,30.80090819999998],[120.32867752699997,30.801011895999977],[120.32862135100004,30.801188737000018],[120.32866250300003,30.801210830000002],[120.32872915899998,30.801203457999975],[120.32876243600003,30.801174563000018],[120.32879561100003,30.801095254000018],[120.32880544199998,30.800836190999973],[120.32892328100002,30.800848293]]]}";
     JObject jObject = JObject.Parse(json);
     Polygon polygon = SpatialDataObtain.GeometryJsonToPolygon(jObject);
 }
예제 #4
0
        public static void ServerDataToGDB(this SpatialDataObtain spatialDataObtain, string serverUrl, string WhereClause, string OutFields, int FeattureNumPerRead)
        {
            string            message;
            string            getUrl;
            IWorkspace        workspace = null;
            IFeatureClass     featureClass = null;
            int               start = 104676;
            esriGeometryType  esriGeometryType = esriGeometryType.esriGeometryAny;
            ISpatialReference spatialReference = null;
            int               max, min;

            for (int i = min; i <= max; i += FeattureNumPerRead)
            {
                if (serverUrl[serverUrl.Length - 1] == '/')
                {
                    getUrl = $"{serverUrl}query?";
                }
                else
                {
                    getUrl = $"{serverUrl}/query?";
                }
                string newWhereClause = string.Format("{0}>={1} and {0}<{2}", "OBJECTID", i, i + FeattureNumPerRead);
                newWhereClause = WhereClause == "" ? newWhereClause : WhereClause + " and " + newWhereClause;
                getUrl         = $"{getUrl}where={newWhereClause}&outFields={(string.IsNullOrEmpty(OutFields) ? "*" : OutFields)}&returnGeometry=true&f=pjson";
                if (GetFilterCount(serverUrl, newWhereClause) <= 0)
                {
                    break;
                }
                //http://192.168.1.137:6080/arcgis/rest/services/HZDG/HZDGJSFAFW/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=OBJECTID%2CXMLB&returnGeometry=true&maxAllowableOffset=10&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=html
                string queryResult = HttpGet(getUrl);
                //FeatureClassSDO featureClassSDO = JsonConvert.DeserializeObject<FeatureClassSDO>(queryResult);
                JObject jObject = JObject.Parse(queryResult);


                if (featureClass == null)
                {
                    JArray keyValuePairs = jObject.Value <JArray>("fields");
                    esriGeometryType = GetGeometryTypeFromName(jObject.Value <string>("geometryType"));
                    JToken spatialRef = jObject.Value <JToken>("spatialReference");
                    int    wkid       = spatialRef.Value <int>("wkid");
                    spatialReference = GetSpatialRefFromWkid(wkid);
                    List <IField> fields = new List <IField>();
                    foreach (var item in keyValuePairs)
                    {
                        JObject    itemObject = item as JObject;
                        IField     field      = new FieldClass();
                        IFieldEdit fieldEdit  = field as IFieldEdit;
                        fieldEdit.Name_2      = itemObject.Value <string>("name");
                        fieldEdit.AliasName_2 = itemObject.Value <string>("alias");
                        fieldEdit.Type_2      = EnumUtil.GetEnumObjByName <esriFieldType>(itemObject.Value <string>("type"));//sourceFields.Field[FieldCount].Type;
                        fields.Add(field);
                    }

                    featureClass = CreateMemoryFeatureClass(fields, spatialReference, esriGeometryType, out workspace);
                }
                while (true)
                {
                }

                JArray features = jObject.Value <JArray>("features");
                List <Dictionary <string, object> > dicExportData = new List <Dictionary <string, object> >();
                foreach (var item in features)
                {
                    Dictionary <string, object> values = new Dictionary <string, object>();
                    JToken attributes = item.Value <JToken>("attributes");
                    foreach (var value in (attributes as JObject).Properties())
                    {
                        values.Add(value.Name, value.Value);
                    }
                    JToken    geometryJson = item.Value <JToken>("geometry");
                    IGeometry geometry     = ConvertToGeometry(geometryJson.ToString(), esriGeometryType);
                    values.Add("geometry", geometry);
                    dicExportData.Add(values);
                }

                exportDataToMemery(dicExportData, featureClass, spatialReference, out message);
            }
        }