Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);
            extent  = context.Request.QueryString["Extent"].Split(new[] { ',' }).Select(Convert.ToDouble).ToList();
            level   = double.Parse(context.Request.QueryString["level"]);
            _config = ConfigHelper.GetConfig(EnumBruTileLayer.OSM);

            _tileSource   = _config.CreateTileSource();
            _tileProvider = (WebTileProvider)_tileSource.Provider;


            _cacheDir = CacheSettings.GetCacheFolder();

            _fileCache = CacheDirectory.GetFileCache(_cacheDir, _config, EnumBruTileLayer.OSM);
            Draw();
            //using (Bitmap map = new Bitmap(@"D:\我的文件\天津师大切片解决方案\DownloadTiles\DownloadTiles\bin\Debug\p.png"))
            using (Bitmap map = mosaicImage())
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    map.Save(mem, ImageFormat.Png);
                    mem.Seek(0, SeekOrigin.Begin);

                    context.Response.ContentType = "image/png";

                    mem.CopyTo(context.Response.OutputStream, 4096);
                    context.Response.Flush();
                }
            }
        }
Ejemplo n.º 2
0
        public void ShapeInWhereTest3()
        {
            //new ArcEngineLicense();
            RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);
            //ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
            var sdeWs = DataActions.GetSdeWorkspace(new Dictionary <string, object>()
            {
                { "INSTANCE", "sde:oracle11g:192.168.0.2/orcl" },
                { "USER", "dzgisdata" },
                { "PASSWORD", "dzgisdata" },
            });



            var outFcname = $@"C:/test/i{DateTime.Now.ToBinary()}.shp";
            var feaWs     = (IFeatureWorkspace)sdeWs;
            var xzqh      = feaWs.OpenFeatureClass("DZGISDATA.XZQH");
            //var ydhx = feaWs.OpenFeatureClass("DZGISDATA.YDHX_SP");

            IVariantArray arr = new VarArrayClass();

            //arr.Add(@"C:\test\dzgisdata02.sde\DZGISDATA.XZQH\DZGISDATA.XZQH");
            arr.Add(outFcname);

            //IGeoProcessor gp2 = new GeoProcessorClass();
            //IGeoProcessorResult result = gp2.Execute("Select", arr, null);
            var gp = new Geoprocessor();


            var result = gp.Execute(new Select()
            {
                in_features       = @"C:\test\continents.shp",
                out_feature_class = outFcname,
            }, null);

            ;

            //Select sel = new Select()
            //{
            //    in_features = xzqh,
            //    out_feature_class = outFcname

            //};
            //var result = new Geoprocessor().Execute(sel, null);

            //var gpResult = (IGeoProcessorResult)result;

            //var gpms = gpResult.GetResultMessages();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);


            IPolyline polyline = new PolylineClass();
            IPoint    point0   = new PointClass()
            {
                X = 0, Y = 0
            };
            IPoint point1 = new PointClass()
            {
                X = 1, Y = 1
            };
            IPoint point2 = new PointClass()
            {
                X = 2, Y = -1
            };

            ((IPointCollection)polyline).AddPoint(point0);
            ((IPointCollection)polyline).AddPoint(point1);
            ((IPointCollection)polyline).AddPoint(point2);
            polyline.GetSubcurve(1, 2, false, out ICurve outCurve);

            var outPolyline        = ((IPolyline)outCurve);
            var outPointCollection = ((IPointCollection)outPolyline);

            for (int i = 0; i < outPointCollection.PointCount; i++)
            {
                Console.WriteLine($"{outPointCollection.Point[i].X} {outPointCollection.Point[i].Y}");
            }


            //Console.WriteLine(((IPointCollection)polyline).PointCount);
            //polyline.SplitAtDistance(1, false, false, out var splitHappened, out var newPartIndex, out var segmentIndex);
            //Console.WriteLine(((IPointCollection)polyline).PointCount);
            //double length = polyline.Length;
            ;
        }
Ejemplo n.º 4
0
 static int Main(string[] args)
 {
     //CreatePoint();
     try
     {
         RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);
         DownloadTask downloadTask = new DownloadTask();
         DateTime     time         = Convert.ToDateTime(args[0]);
         string       _extent      = args[1];
         string       basePath     = args[2];
         string       tileDir      = args[3];
         string       csv          = args[4];
         downloadTask.DoMainTask(time, _extent, basePath, tileDir, csv);
     }
     catch (Exception ex)
     {
         LogManager.LogPath = AppDomain.CurrentDomain.BaseDirectory + "\\log\\";
         LogManager.WriteLog("error", ex.Message);
         return(-1);
     }
     LogManager.LogPath = AppDomain.CurrentDomain.BaseDirectory + "\\log\\";
     LogManager.WriteLog("state", "执行任务成功!");
     return(2);
 }
Ejemplo n.º 5
0
 public static void BindLicense()
 {
     RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            bool   showHelp    = false;
            bool   gzip        = false;
            bool   overwrite   = false;
            bool   verbose     = false;
            string destination = ".";

            int[]            levels = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
            HashSet <string> fields = null;
            int threadCount         = System.Environment.ProcessorCount;

            OptionSet p = new OptionSet()
            {
                { "d|dir=", "destination directory (defaults to current directory)", d => destination = d },
                { "l|levels=",
                  "list of scale levels [0-19], separated by commas",
                  l => levels = l.Split(new char[] { ',' }).Select(s => Convert.ToInt32(s)).ToArray() },
                { "f|fields=",
                  "list of field names to include in UTFGrid data",
                  f => fields = new HashSet <string>(f.Split(new char[] { ',' })) },
                { "t|threads=",
                  "number of threads to use (defaults to number of processors)",
                  t => threadCount = Convert.ToInt32(t) },
                { "z|zip", "zip the json files using gzip compression before saving", z => gzip = z != null },
                { "o|overwrite", "overwrite existing files", o => overwrite = o != null },
                { "v|verbose", "verbose output", v => verbose = v != null },
                { "h|help", "show this message and exit", h => showHelp = h != null }
            };
            List <string> extra;

            try {
                extra = p.Parse(args);
            } catch (OptionException e) {
                Console.Write("utfgrid");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `utfgrid --help' for more information.");
                return;
            }
            if (showHelp)
            {
                Console.WriteLine("Usage: utfgrid [OPTIONS]+ mxd_document");
                Console.WriteLine("Generate UTFGrid files from the given map document");
                Console.WriteLine();
                Console.WriteLine("Options:");
                p.WriteOptionDescriptions(Console.Out);
                return;
            }
            else if (extra.Count < 1)
            {
                Console.WriteLine("utfgrid: no map document specified");
                Console.WriteLine("Try `utfgrid --help' for more information.");
                return;
            }
            RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);

            IMap map = null;

            try {
                IMapDocument mapDocument = new MapDocumentClass();
                mapDocument.Open(extra[0], null);
                map = mapDocument.ActiveView as IMap;
                if (map == null)
                {
                    map = mapDocument.get_Map(0);
                }
                mapDocument.Close();
            } catch (Exception) { }
            if (map == null)
            {
                Console.WriteLine("Unable to open map at " + extra[0]);
                return;
            }
            if ((map.SpatialReference.FactoryCode != 102113) &&
                (map.SpatialReference.FactoryCode != 102100) &&
                (map.SpatialReference.FactoryCode != 3785))
            {
                Console.WriteLine("Spatial reference of map must be Web Mercator (is " + map.SpatialReference.FactoryCode + ")");
                return;
            }

            IActiveView activeView = map as IActiveView;
            // get the extent from the active view
            IEnvelope fullExtent = activeView.FullExtent;

            Console.WriteLine("starting utfgrid generator with " + threadCount + " threads");

            UTFGridGeneratorConfig config = new UTFGridGeneratorConfig(extra[0], DescribeTiles(levels, activeView.FullExtent));

            config.GZip        = gzip;
            config.Overwrite   = overwrite;
            config.Verbose     = verbose;
            config.Destination = destination;

            Thread[] workerThreads = new Thread[threadCount];

            for (int i = 0; i < threadCount; i++)
            {
                workerThreads[i] = new Thread(new ParameterizedThreadStart(UTFGridGenerator.Execute));
                workerThreads[i].SetApartmentState(ApartmentState.STA);
                workerThreads[i].IsBackground = true;
                workerThreads[i].Priority     = ThreadPriority.BelowNormal;
                workerThreads[i].Name         = "UTFGridGenerator " + (i + 1).ToString();
                workerThreads[i].Start(config);
            }

            foreach (Thread t in workerThreads)
            {
                t.Join();
            }
            workerThreads = null;
        }