public IActionResult EsriMap(string cmd, string ServiceName, string content)
        {
            if (cmd == "ping")
            {
                return(Result("gView MapServer Instance v" + gView.Framework.system.SystemVariables.gViewVersion.ToString(), "text/plain"));
            }
            if (cmd == "getversion")
            {
                return(Result(gView.Framework.system.SystemVariables.gViewVersion.ToString(), "text/plain"));
            }
            if (cmd == "capabilities")
            {
                content = @"<?xml version=""1.0"" encoding=""UTF-8""?><ARCXML version=""1.1""><REQUEST><GET_SERVICE_INFO fields=""true"" envelope=""true"" renderer=""true"" extensions=""true"" /></REQUEST></ARCXML>";
            }

            var interpreter = InternetMapServer.GetInterpreter(typeof(ArcXMLRequest));

            #region Request

            if (String.IsNullOrEmpty(content) && Request.Body.CanRead)
            {
                MemoryStream ms = new MemoryStream();

                byte[] bodyData = new byte[1024];
                int    bytesRead;
                while ((bytesRead = Request.Body.Read(bodyData, 0, bodyData.Length)) > 0)
                {
                    ms.Write(bodyData, 0, bytesRead);
                }
                content = Encoding.UTF8.GetString(ms.ToArray());
            }

            ServiceRequest serviceRequest = new ServiceRequest(ServiceName, content);
            serviceRequest.OnlineResource = InternetMapServer.OnlineResource;

            #endregion

            #region Security

            Identity identity = Identity.FromFormattedString(String.Empty);
            identity.HashedPassword = String.Empty;
            serviceRequest.Identity = identity;

            #endregion

            #region Queue & Wait

            IServiceRequestContext context = new ServiceRequestContext(
                InternetMapServer.Instance,
                interpreter,
                serviceRequest);

            InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context);

            #endregion

            return(Result(serviceRequest.Response, "text/xml"));
        }
Beispiel #2
0
        public IActionResult Legend(string folder, string id)
        {
            try
            {
                if (folder != DefaultFolder)
                {
                    throw new Exception("Unknown folder: " + folder);
                }

                var interpreter = InternetMapServer.GetInterpreter(typeof(ArcGisServerInterperter));

                #region Request

                ServiceRequest serviceRequest = new ServiceRequest(id, String.Empty)
                {
                    OnlineResource = InternetMapServer.OnlineResource,
                    Method         = "legend"
                };

                #endregion

                #region Security

                Identity identity = Identity.FromFormattedString(String.Empty);
                identity.HashedPassword = String.Empty;
                serviceRequest.Identity = identity;

                #endregion

                #region Queue & Wait

                IServiceRequestContext context = new ServiceRequestContext(
                    InternetMapServer.Instance,
                    interpreter,
                    serviceRequest);

                InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context);

                #endregion

                return(Result(JsonConvert.DeserializeObject <LegendResponse>(serviceRequest.Response)));
            }
            catch (Exception ex)
            {
                return(Json(new JsonError()
                {
                    error = new JsonError.Error()
                    {
                        code = 999, message = ex.Message
                    }
                }));
            }
        }
Beispiel #3
0
        public IActionResult GetMetadata(string name)
        {
            try
            {
                string user = String.Empty, pwd = String.Empty;
                // var request = Request(out user, out pwd);

                string ret = InternetMapServer.GetMetadata(name, user, pwd);

                return(Result(ret, "text/xml"));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }
Beispiel #4
0
        public IActionResult RemoveMap(string name)
        {
            try
            {
                string user = String.Empty, pwd = String.Empty;
                // var request = Request(out user, out pwd);

                bool ret = InternetMapServer.RemoveMap(name, user, pwd);

                return(Result(ret.ToString(), "text/plain"));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }
Beispiel #5
0
        public IActionResult SetMetadata(string name)
        {
            try
            {
                string input = GetBody();

                string user = String.Empty, pwd = String.Empty;
                // var request = Request(out user, out pwd);

                bool ret = InternetMapServer.SetMetadata(name, input, user, pwd);

                return(Result(ret.ToString(), "text/plain"));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }
Beispiel #6
0
        public IActionResult OgcRequest(string id, string service = "")
        {
            try
            {
                IServiceRequestInterpreter interpreter = null;

                switch (service.ToLower().Split(',')[0])
                {
                case "wms":
                    interpreter = InternetMapServer.GetInterpreter(typeof(WMSRequest));
                    break;

                case "wfs":
                    interpreter = InternetMapServer.GetInterpreter(typeof(WFSRequest));
                    break;

                case "wmts":
                    interpreter = InternetMapServer.GetInterpreter(typeof(WMTSRequest));
                    break;

                default:
                    throw new Exception("Missing or unknow service: " + service);
                }

                #region Request

                string requestString = Request.QueryString.ToString();

                if (Request.Method.ToLower() == "post" && Request.Body.CanRead)
                {
                    MemoryStream ms = new MemoryStream();

                    byte[] bodyData = new byte[1024];
                    int    bytesRead;
                    while ((bytesRead = Request.Body.Read(bodyData, 0, bodyData.Length)) > 0)
                    {
                        ms.Write(bodyData, 0, bytesRead);
                    }
                    string body = Encoding.UTF8.GetString(ms.ToArray());

                    if (!String.IsNullOrWhiteSpace(body))
                    {
                        requestString = body;
                    }
                }

                while (requestString.StartsWith("?"))
                {
                    requestString = requestString.Substring(1);
                }

                ServiceRequest serviceRequest = new ServiceRequest(id, requestString);
                serviceRequest.OnlineResource = InternetMapServer.OnlineResource + "/ogc/" + id;

                #endregion

                #region Security

                Identity identity = Identity.FromFormattedString(String.Empty);
                identity.HashedPassword = String.Empty;
                serviceRequest.Identity = identity;

                #endregion

                IServiceRequestContext context = new ServiceRequestContext(
                    InternetMapServer.Instance,
                    interpreter,
                    serviceRequest);

                InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context);

                return(Result(serviceRequest.Response, "text/xml"));
            }
            catch (Exception ex)
            {
                // ToDo: OgcXmlExcpetion
                return(Result(ex.Message, "text/plain"));
            }
        }
Beispiel #7
0
        public IActionResult FeatureServerDeleteFeatures(string folder, string id, int layerId)
        {
            try
            {
                if (folder != DefaultFolder)
                {
                    throw new Exception("Unknown folder: " + folder);
                }

                var interpreter = InternetMapServer.GetInterpreter(typeof(ArcGisServerInterperter));

                #region Request

                JsonFeatureServerEditRequest editRequest = Deserialize <JsonFeatureServerEditRequest>(
                    Request.HasFormContentType ?
                    (IEnumerable <KeyValuePair <string, StringValues> >)Request.Form :
                    (IEnumerable <KeyValuePair <string, StringValues> >)Request.Query);
                editRequest.LayerId = layerId;

                ServiceRequest serviceRequest = new ServiceRequest(id, JsonConvert.SerializeObject(editRequest))
                {
                    OnlineResource = InternetMapServer.OnlineResource,
                    Method         = "featureserver_deletefeatures"
                };

                #endregion

                #region Security

                Identity identity = Identity.FromFormattedString(String.Empty);
                identity.HashedPassword = String.Empty;
                serviceRequest.Identity = identity;

                #endregion

                #region Queue & Wait

                IServiceRequestContext context = new ServiceRequestContext(
                    InternetMapServer.Instance,
                    interpreter,
                    serviceRequest);

                InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context);

                #endregion

                return(Result(JsonConvert.DeserializeObject <JsonFeatureServerResponse>(serviceRequest.Response)));
            }
            catch (Exception ex)
            {
                return(Result(new JsonFeatureServerResponse()
                {
                    DeleteResults = new JsonFeatureServerResponse.JsonResponse[]
                    {
                        new JsonFeatureServerResponse.JsonResponse()
                        {
                            Success = false,
                            Error = new JsonFeatureServerResponse.JsonError()
                            {
                                Code = 999,
                                Description = ex.Message
                            }
                        }
                    }
                }));
            }
        }
Beispiel #8
0
        public IActionResult Query(string folder, string id, int layerId)
        {
            try
            {
                if (folder != DefaultFolder)
                {
                    throw new Exception("Unknown folder: " + folder);
                }

                var interpreter = InternetMapServer.GetInterpreter(typeof(ArcGisServerInterperter));

                #region Request

                JsonQueryLayer queryLayer = Deserialize <JsonQueryLayer>(
                    Request.HasFormContentType ?
                    (IEnumerable <KeyValuePair <string, StringValues> >)Request.Form :
                    (IEnumerable <KeyValuePair <string, StringValues> >)Request.Query);
                queryLayer.LayerId = layerId;

                ServiceRequest serviceRequest = new ServiceRequest(id, JsonConvert.SerializeObject(queryLayer))
                {
                    OnlineResource = InternetMapServer.OnlineResource,
                    Method         = "query"
                };

                #endregion

                #region Security

                Identity identity = Identity.FromFormattedString(String.Empty);
                identity.HashedPassword = String.Empty;
                serviceRequest.Identity = identity;

                #endregion

                #region Queue & Wait

                IServiceRequestContext context = new ServiceRequestContext(
                    InternetMapServer.Instance,
                    interpreter,
                    serviceRequest);

                InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context);

                #endregion

                if (serviceRequest.Succeeded)
                {
                    if (queryLayer.ReturnCountOnly == true)
                    {
                        return(Result(JsonConvert.DeserializeObject <JsonFeatureCountResponse>(serviceRequest.Response)));
                    }
                    else
                    {
                        return(Result(JsonConvert.DeserializeObject <JsonFeatureResponse>(serviceRequest.Response)));
                    }
                }
                else
                {
                    return(Result(JsonConvert.DeserializeObject <JsonError>(serviceRequest.Response)));
                }
            }
            catch (Exception ex)
            {
                return(Json(new JsonError()
                {
                    error = new JsonError.Error()
                    {
                        code = 999, message = ex.Message
                    }
                }));
            }
        }
Beispiel #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                // ArcGIS Server
                routes.MapRoute(
                    name: "arcgis_rest_exportmap",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/export",
                    defaults: new { controller = "ArcGis", Action = "ExportMap" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_query",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/{layerId}/query",
                    defaults: new { controller = "ArcGis", Action = "Query" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_servicelayers",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/layers",
                    defaults: new { controller = "ArcGis", Action = "ServiceLayers" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_servicelegend",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/legend",
                    defaults: new { controller = "ArcGis", Action = "Legend" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_servicelayer",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/{layerId}",
                    defaults: new { controller = "ArcGis", Action = "ServiceLayer" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_service",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver",
                    defaults: new { controller = "ArcGis", Action = "Service" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_folder",
                    template: "arcgis/rest/services/{id}",
                    defaults: new { controller = "ArcGis", Action = "Folder" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_services",
                    template: "arcgis/rest/services",
                    defaults: new { controller = "ArcGis", Action = "Services" }
                    );

                routes.MapRoute(
                    name: "arcgis_rest_featureserver_query",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/query",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerQuery" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_featureserver_addfeatures",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/addfeatures",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerAddFeatures" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_featureserver_updatefeatures",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/updatefeatures",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerUpdateFeatures" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_featureserver_deletefeatures",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/deletefeatures",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerDeleteFeatures" }
                    );

                // Ogc
                routes.MapRoute(
                    name: "ogc_request",
                    template: "ogc/{id}",
                    defaults: new { controller = "Ogc", Action = "OgcRequest" }
                    );

                // ArcIMS
                routes.MapRoute(
                    name: "ags-servlet",
                    template: "servlet/com.esri.esrimap.Esrimap",
                    defaults: new { controller = "ArcIMS", Action = "Esrimap" }
                    );
                routes.MapRoute(
                    name: "ags-servlet2",
                    template: "arcims/servlet/com.esri.esrimap.Esrimap",
                    defaults: new { controller = "ArcIMS", Action = "Esrimap" }
                    );

                // MapServer
                routes.MapRoute(
                    name: "mapserver-catelog",
                    template: "catalog",
                    defaults: new { controller = "MapServer", Action = "Catalog" }
                    );
                routes.MapRoute(
                    name: "mapserver-maprequest",
                    template: "MapRequest/{guid}/{id}",
                    defaults: new { controller = "MapServer", Action = "MapRequest" }
                    );
                routes.MapRoute(
                    name: "mapserver-addmap",
                    template: "AddMap/{name}",
                    defaults: new { controller = "MapServer", Action = "AddMap" }
                    );
                routes.MapRoute(
                    name: "mapserver-remotemap",
                    template: "RemoveMap/{name}",
                    defaults: new { controller = "MapServer", Action = "RemoveMap" }
                    );
                routes.MapRoute(
                    name: "mapserver-getmetadata",
                    template: "GetMetadata/{name}",
                    defaults: new { controller = "MapServer", Action = "GetMetadata" }
                    );
                routes.MapRoute(
                    name: "mapserver-setmetadata",
                    template: "SetMetadata/{name}",
                    defaults: new { controller = "MapServer", Action = "SetMetadata" }
                    );

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            PlugInManager.Init();

            InternetMapServer.Init(env.ContentRootPath);
            //InternetMapServer.Init(@"C:\Development_OpenSource\GeoDaten\MXL\8050");
        }
Beispiel #10
0
        public IActionResult MapRequest(string guid, string id)
        {
            try
            {
                if (IfMatch())
                {
                    return(NotModified());
                }

                //DateTime td = DateTime.Now;
                //Console.WriteLine("Start Map Request " + td.ToLongTimeString() + "." + td.Millisecond + " (" + name + ")");
                //System.Threading.Thread.Sleep(10000);

                //string user, pwd;
                //var request = Request(out user, out pwd);

                #region Request

                string input = String.Empty;
                if (Request.Body.CanRead)
                {
                    MemoryStream ms = new MemoryStream();

                    byte[] bodyData = new byte[1024];
                    int    bytesRead;
                    while ((bytesRead = Request.Body.Read(bodyData, 0, bodyData.Length)) > 0)
                    {
                        ms.Write(bodyData, 0, bytesRead);
                    }
                    input = Encoding.UTF8.GetString(ms.ToArray());
                }
                if (String.IsNullOrEmpty(input))
                {
                    input = this.Request.QueryString.ToString();
                }
                if (input.StartsWith("?"))
                {
                    input = input.Substring(1);
                }

                ServiceRequest serviceRequest = new ServiceRequest(id, input);
                serviceRequest.OnlineResource = InternetMapServer.OnlineResource + "/MapRequest/" + guid + "/" + id;

                #endregion

                IServiceRequestInterpreter interpreter =
                    InternetMapServer.GetInterpreter(new Guid(guid));

                #region Security

                Identity identity = Identity.FromFormattedString(String.Empty);
                identity.HashedPassword = String.Empty;
                serviceRequest.Identity = identity;

                #endregion

                #region Queue & Wait

                IServiceRequestContext context = new ServiceRequestContext(
                    InternetMapServer.Instance,
                    interpreter,
                    serviceRequest);

                InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context);

                #endregion

                string ret = serviceRequest.Response;

                return(Result(ret, "text/xml"));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }