{"id":18,"date":"2009-11-07T21:06:00","date_gmt":"2009-11-07T21:06:00","guid":{"rendered":"http:\/\/blog.newnaw.com\/?p=18"},"modified":"2009-11-07T21:06:00","modified_gmt":"2009-11-07T21:06:00","slug":"arcgis%e4%b8%ad%e7%9a%84%e7%ba%bf%e6%80%a7%e5%8f%82%e8%80%83%e5%8a%a8%e6%80%81%e5%88%86%e6%ae%b5%e6%8a%80%e6%9c%af%ef%bc%88%e4%b8%89%ef%bc%89%e5%87%a0%e4%b8%aalinear-referencing%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/blog.newnaw.com\/?p=18","title":{"rendered":"ArcGIS\u4e2d\u7684\u7ebf\u6027\u53c2\u8003\/\u52a8\u6001\u5206\u6bb5\u6280\u672f\uff08\u4e09\uff09\u51e0\u4e2aLinear Referencing\u5e94\u7528\u573a\u666f\u5728AGS\u4e2d\u7684\u5b9e\u73b0"},"content":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u73b0\u5728\u6765\u5b9e\u73b0\u4e0a\u9762\u63d0\u5230\u76843\u4e2a\u529f\u80fd\u3002<br \/><span style=\"font-weight: bold; color: rgb(51, 102, 255);font-size:130%;\">1\u3001\u5bf9\u4e8e\u67d0\u6761\u516c\u8def\u4e0a\u7684\u4e00\u70b9\u8fdb\u884cIdentify\u64cd\u4f5c\uff0c\u8981\u6c42\u8fd4\u56de\u8be5\u70b9\u5728\u516c\u8def\u4e0a\u7684\u6869\u53f7\u503c\uff1a<\/span><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4ee5Silverlight API\u4e3a\u4f8b\u3002\u4e3a\u4e86\u5728\u670d\u52a1\u5668\u7aef\u4f7f\u7528ArcObjects\uff0c\u5728Asp.net\u5de5\u7a0b\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3aLinearRef\u7684Silverlight-Enabled WCF Service\uff0c\u5728LinearRef.svc.cs\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<br \/><code><br \/>namespace RoadDycSeg.Web.WCF<br \/>{<br \/>    [ServiceContract(Namespace = \"\")]<br \/>    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]<br \/>    public class LinearRef<br \/>    {<br \/>        public IRouteLocator2 pRtLocator = null;<br \/>        ESRI.ArcGIS.Server.IServerObjectManager pSOM = null;<br \/>        public ESRI.ArcGIS.Server.IServerContext pServerContext = null;<\/p>\n<p>        public LinearRef()<br \/>        {<br \/>            ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(\"ArcGISWebServices\", \"yourpassword\", \"\");<br \/>            ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconn = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(\"localhost\", identity);<br \/>            agsconn.Connect();<br \/>            pSOM = agsconn.ServerObjectManager;<br \/>            pServerContext = pSOM.CreateServerContext(\"shaanxi\", \"MapServer\");<br \/>            ESRI.ArcGIS.Carto.IMapServer2 pMapServer = pServerContext.ServerObject as ESRI.ArcGIS.Carto.IMapServer2;<br \/>            ESRI.ArcGIS.Carto.IMapServerObjects2 pMapServerObjects = pMapServer as ESRI.ArcGIS.Carto.IMapServerObjects2;<br \/>            ESRI.ArcGIS.Carto.IMap pMap = pMapServerObjects.get_Map(pMapServer.DefaultMapName);<br \/>            IFeatureClass pFC = (pMap.get_Layer(2) as ESRI.ArcGIS.Carto.IFeatureLayer).FeatureClass;<\/p>\n<p>            \/\/create the RouteLocator<br \/>            IDataset dS = (IDataset)pFC; \/\/ A polylineM feature class.<br \/>            IName name = dS.FullName;<br \/>            IRouteLocatorName rtLocatorName = pServerContext.CreateObject(\"esriLocation.RouteMeasureLocatorName\") as IRouteLocatorName;<br \/>            rtLocatorName.RouteFeatureClassName = name;<br \/>            rtLocatorName.RouteIDFieldName = \"\u9053\u8def\u7f16\u7801\";<br \/>            rtLocatorName.RouteMeasureUnit = esriUnits.esriUnknownUnits;<br \/>            name = (IName)rtLocatorName;<br \/>            pRtLocator = (IRouteLocator2)name.Open();<\/p>\n<p>            pServerContext.ReleaseContext();<br \/>        }<\/p>\n<p>\/\/ Add more operations here and mark them with [OperationContract]<\/p>\n<p>        [OperationContract]<br \/>        \/\/\/ <\/p>\n<summary>        \/\/\/ used by the client Identify operation and return the result<br \/>        \/\/\/ <\/summary>\n<p>        \/\/\/ <param name=\"mapX\">the x coords of the mouseclick in map units<\/param>        \/\/\/ <param name=\"mapY\">the y coords of the mouseclick in map units<\/param>        \/\/\/ <param name=\"resolution\">the map distance of 1 pixel<\/param>        \/\/\/ <returns>a identifyresult class defined in Classes.cs. If no result, mvalue=x=y=-1<\/returns><br \/>        public IdentifyResult Identify(double mapX, double mapY, double resolution)<br \/>        {<br \/>            pServerContext = pSOM.CreateServerContext(\"shaanxi\", \"MapServer\");<\/p>\n<p>            IdentifyResult ir = new IdentifyResult(\"\", -1, -1, -1);<\/p>\n<p>            IPoint pPoint = pServerContext.CreateObject(\"esriGeometry.Point\") as IPoint;<br \/>            pPoint.PutCoords(mapX, mapY);<br \/>            IEnvelope pEnvelope = pPoint.Envelope;<br \/>            pEnvelope.Expand(10 * resolution, 10 * resolution, false);<\/p>\n<p>            IEnumRouteIdentifyResult pEnumResult = pRtLocator.Identify(pEnvelope, \"\");<br \/>            pEnumResult.Reset();<br \/>            \/\/only get the first result<br \/>            if (pEnumResult.Count > 0)<br \/>            {<br \/>                IRouteLocation pRL = null;<br \/>                IFeature pF = null;<br \/>                pEnumResult.Next(out pRL, out pF);<br \/>                IRouteMeasurePointLocation pRMPL = pRL as IRouteMeasurePointLocation;<\/p>\n<p>                \/\/retrieve the location geometry by calling LOCATE method<br \/>                IRouteLocation routeLocation = pServerContext.CreateObject(\"esriLocation.RouteMeasurePointLocation\") as IRouteLocation;<br \/>                routeLocation.MeasureUnit = esriUnits.esriUnknownUnits;<br \/>                routeLocation.RouteID = pRL.RouteID;<br \/>                routeLocation.LateralOffset = 0;<br \/>                IRouteMeasurePointLocation rMPointLoc = (IRouteMeasurePointLocation)routeLocation;<br \/>                rMPointLoc.Measure = pRMPL.Measure;<\/p>\n<p>                IGeometry geom;<br \/>                esriLocatingError locError;<br \/>                pRtLocator.Locate((IRouteLocation)rMPointLoc, out geom, out locError);<\/p>\n<p>                ir.RouteID = pRL.RouteID.ToString();<br \/>                ir.MValue = pRMPL.Measure;<br \/>                ir.X = (geom as IPointCollection5).get_Point(0).X;<br \/>                ir.Y = (geom as IPointCollection5).get_Point(0).Y;<br \/>            }<\/p>\n<p>            pServerContext.ReleaseContext();<\/p>\n<p>            return ir;<br \/>        }<br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5176\u4e2d\uff0cIdentifyResult\u662f\u81ea\u5b9a\u4e49\u7684\u4e00\u4e2a\u7c7b\uff0c\u7528\u6765\u5b58\u50a8\u67e5\u8be2\u7684\u7ed3\u679c\uff1a<br \/><code>namespace RoadDycSeg.Web.WCF<br \/>{<br \/>    \/\/\/ <\/p>\n<summary>    \/\/\/ the result of Identify operation<br \/>    \/\/\/ <\/summary>\n<p>    [DataContract]<br \/>    public class IdentifyResult<br \/>    {<br \/>        [DataMember]<br \/>        public string RouteID {get;set;}<br \/>        [DataMember]<br \/>        public double MValue {get;set;}<br \/>        [DataMember]<br \/>        public double X {get;set;}<br \/>        [DataMember]<br \/>        public double Y {get;set;}<\/p>\n<p>        public IdentifyResult(string routeid, double mvalue, double x, double y)<br \/>        {<br \/>            RouteID = routeid;<br \/>            MValue = mvalue;<br \/>            X = x;<br \/>            Y = y;<br \/>        }<br \/>    }<br \/>}<br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Identify\u65b9\u6cd5\u9700\u8981\u4f20\u51653\u4e2a\u53c2\u6570\uff0c\u4e00\u4e2a\u70b9\u7684\u5730\u7406\u5750\u6807\u4ee5\u53ca\u5f53\u524d\u5730\u56fe\u7684Resolution\uff0c\u540e\u8005\u7528\u6765\u751f\u6210\u4e00\u4e2a10\u50cf\u7d20\u7684\u7f13\u51b2\u533a\uff0c\u65b9\u4fbf\u7528\u6237\u7684\u70b9\u51fb\u64cd\u4f5c\uff1b\u5176\u4e2d\u5229\u7528IRouteLocator2.Identify\u65b9\u6cd5\u83b7\u5f97M\u503c\uff0c\u636e\u6b64\u5229\u7528 IRouteLocator2.Locate\u65b9\u6cd5\u83b7\u5f97\u7cbe\u786e\u843d\u5728\u516c\u8def\u4e0a\u7684\u70b9\u7684Geometry\uff0c\u7528\u4ee5\u663e\u793a\u5728\u5ba2\u6237\u7aef\uff1b\u5982\u679c\u7528\u6237\u70b9\u51fb\u7684\u70b9\u8ddd\u79bb\u516c\u8def\u8f83\u8fdc\uff0c\u5219IRouteLocator2.Identify\u7ed3\u679c\u4e3a\u7a7a\uff0c\u8fd4\u56de\u7684IdentifyResult\u4e2dM\u503c\u4e3a-1\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5728Silverlight\u5de5\u7a0b\u4e2d\uff0cAdd Service Reference\uff0c\u627e\u5230\u521a\u624d\u7684LinearRef\u670d\u52a1\uff0c\u53d6\u540d\u4e3aLRService\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5ba2\u6237\u7aef\u4e2d\uff0c\u65b0\u5efa\u4e00\u4e2aCOperation\u7c7b\uff0c\u5b9e\u73b0\u4e1a\u52a1\u64cd\u4f5c\u3002<br \/><code>public class COperation<br \/>{<br \/>private LRService.LinearRefClient LR = null;<br \/>        private GraphicsLayer glayer = null;<br \/>        private bool isBusy = false;\/\/indicate whether there is an operation is performing<br \/>        private Map Map1 = null;<br \/>        public COperation(Map map)<br \/>        {<br \/>            Map1=map;<br \/>            glayer = Map1.Layers[\"glayer\"] as GraphicsLayer;<br \/>            \/\/initialize the LR object<br \/>            LR = new RoadDycSeg.LRService.LinearRefClient();<br \/>            LR.IdentifyCompleted += new EventHandler<roaddycseg.lrservice.identifycompletedeventargs>(LR_IdentifyCompleted);<br \/>        }<br \/>        private void LR_IdentifyCompleted(object sender, LRService.IdentifyCompletedEventArgs e)<br \/>        {<br \/>            LRService.IdentifyResult ir = e.Result;<br \/>            \/\/add a point graphic to the map with attributes displaying by the maptip, maptip defined in mainpage.xaml<br \/>            if (ir.X > 0)\/\/the result exists<br \/>            {<br \/\n>                Graphic g = new Graphic()<br \/>                {<br \/>                    Geometry = new MapPoint(ir.X, ir.Y),<br \/>                    Symbol = Application.Current.Resources[\"strobeSymbol\"] as Symbol,<br \/>                };<br \/>                g.Attributes.Add(\"RouteID\", ir.RouteID);<br \/>                g.Attributes.Add(\"\u6869\u53f7\", ir.MValue);<br \/>                g.Attributes.Add(\"X\u5750\u6807\", ir.X);<br \/>                g.Attributes.Add(\"Y\u5750\u6807\", ir.Y);<br \/>                glayer.Graphics.Clear();<br \/>                glayer.Graphics.Add(g);<br \/>            }<br \/>            isBusy = false;<br \/>        }<\/p>\n<p>        private void Map1_Identify(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)<br \/>        {<br \/>            if (!isBusy)<br \/>            {<br \/>                LR.IdentifyAsync(e.MapPoint.X, e.MapPoint.Y, Map1.Resolution);<br \/>                isBusy = true;<br \/>            }<br \/>        }<br \/><\/roaddycseg.lrservice.identifycompletedeventargs><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5728\u9700\u8981\u4f7f\u7528Identify\u529f\u80fd\u65f6\uff0c\u5c06Map\u63a7\u4ef6\u7684Click\u4e8b\u4ef6\u7ed1\u5b9a\u5230Map1_Identify\u5373\u53ef\u3002\u7ed3\u679c\u5982\u56fe\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/3.bp.blogspot.com\/_DD8LUY9p6iU\/SvVy_X8mYXI\/AAAAAAAAAWI\/x72zc_mbbtY\/s1600-h\/LR_6.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 268px;\" src=\"http:\/\/3.bp.blogspot.com\/_DD8LUY9p6iU\/SvVy_X8mYXI\/AAAAAAAAAWI\/x72zc_mbbtY\/s400\/LR_6.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401349761186292082\" \/><\/a><br \/><span style=\"font-weight: bold; color: rgb(51, 102, 255);font-size:130%;\">2\u3001\u8f93\u5165\u8d77\u59cb\u548c\u7ec8\u6b62\u6869\u53f7\uff0c\u8981\u6c42\u5c06\u5176\u95f4\u7684\u8def\u6bb5\u663e\u793a\u5728\u5730\u56fe\u4e0a\uff1a<\/span><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5173\u952e\u662f\u6839\u636e\u4e24\u4e2aM\u503c\uff0c\u6c42\u7684\u5176\u95f4\u4e00\u6bb5\u516c\u8def\u7684Geometry\u3002\u5229\u7528\u7684\u4ecd\u7136\u662fIRouteLocator2.Locate\u65b9\u6cd5\uff0c\u5176\u4e2d\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570routeLocation\uff0c\u4f20\u5165\u7684\u662f\u7528IRouteMeasureLineLocation\u63a5\u53e3\u5b9a\u4e49\u7684\u201c\u7ebf\u6027\u4f4d\u7f6e\u201d\uff0c\u5177\u4f53\u53ef\u53c2\u8003\u5e2e\u52a9\u6587\u6863\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4ecd\u7136\u662f\u5728LinearRef.svc.cs\u6587\u4ef6\u7684LinearRef\u7c7b\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u65b9\u6cd5\uff1a<br \/><code>[OperationContract(Name = \"RetrieveRoutePortionGeometry\")]<br \/>        \/\/\/ <\/p>\n<summary>        \/\/\/ used by the client,such as QueryPortion operation, to retrieve the geometry of the route portion<br \/>        \/\/\/ <\/summary>\n<p>        \/\/\/ <param name=\"routeid\">the route id which the portion is part of<\/param>        \/\/\/ <param name=\"fromMValue\">fromMvalue<\/param>        \/\/\/ <param name=\"toMValue\">toMvalue<\/param>        \/\/\/ <returns>a json string with specific format,such as [{\"x\":1111,\"y\":1111},{\"x\":2222,\"y\":2222},{\"x\":3333,\"y\":3333}.....]<\/returns><br \/>        public string RetrieveRoutePortionGeometry(string routeid, double fromMValue, double toMValue)<br \/>        {<br \/>            pServerContext = pSOM.CreateServerContext(\"shaanxi\", \"MapServer\");<br \/>            IRouteLocation routeLoc = pServerContext.CreateObject(\"esriLocation.RouteMeasureLineLocation\") as IRouteLocation;<br \/>            routeLoc.MeasureUnit = esriUnits.esriUnknownUnits;<br \/>            routeLoc.RouteID = routeid;<br \/>            routeLoc.LateralOffset = 0;<br \/>            IRouteMeasureLineLocation rMLineLoc = (IRouteMeasureLineLocation)routeLoc;<br \/>            rMLineLoc.FromMeasure = fromMValue;<br \/>            rMLineLoc.ToMeasure = toMValue;<\/p>\n<p>            IGeometry geom;<br \/>            esriLocatingError locError;<br \/>            pRtLocator.Locate((IRouteLocation)rMLineLoc, out geom, out locError);<\/p>\n<p>            pServerContext.ReleaseContext();<\/p>\n<p>            \/\/return the routeportion's vertices<br \/>            StringBuilder sb = new StringBuilder(\"[\");<br \/>            IPolyline pLine = geom as IPolyline;<br \/>            IPointCollection pPC = pLine as IPointCollection;<br \/>            \/\/json format such as:<br \/>            \/\/[{\"x\":1111,\"y\":1111},{\"x\":2222,\"y\":2222},{\"x\":3333,\"y\":3333}.....]<br \/>            for (int i = 0; i < pPC.PointCount; i++)<br \/>            {<br \/>                sb.Append(\"{\"x\":\");<br \/>                sb.Append(pPC.get_Point(i).X.ToString());<br \/>                sb.Append(\",\"y\":\");<br \/>                sb.Append(pPC.get_Point(i).Y.ToString());<br \/>                sb.Append(\"},\");<br \/>            }<br \/>            \/\/remove the last \",\"<br \/>            sb.Remove(sb.Length - 1, 1);<br \/>            sb.Append(\"]\");<br \/>            return sb.ToString();<br \/>        }<\/p>\n<p><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u7531\u4e8e\u5728\u670d\u52a1\u5668\u7aef\u7684AO\u64cd\u4f5c\uff0c\u4ea7\u751f\u7684\u7ed3\u679c\u662fESRI.ArcGIS.Geometry.IGeometry\u7c7b\u578b\uff0c\u800c\u5ba2\u6237\u7aef\u9700\u8981\u7684\u5219\u662fESRI.ArcGIS.Client.Geometry.Geometry\u7c7b\u578b\uff0c\u6240\u4ee5\u9700\u8981\u5bf9\u7ed3\u679c\u5e8f\u5217\u5316\/\u53cd\u5e8f\u5217\u5316\uff0c\u8fd9\u91cc\u91c7\u7528JSON\u5b57\u7b26\u4e32\u5904\u7406\u3002\u5ba2\u6237\u7aef\u5904\u7406\u7ed3\u679c\u7684\u51fd\u6570\u4ecd\u7136\u653e\u5728COperation.cs\u6587\u4ef6\u4e2d\uff0c\u5982\u4e0b\uff1a<br \/><code>private void LR_RetrieveRoutePortionGeometryCompleted(object sender,LRService.RetrieveRoutePortionGeometryCompletedEventArgs e)<br \/>        {<br \/>            \/\/create a esri.arcgis.client.geometry.polyline from the coords of points contained in the json string<br \/>            string jsonpoints = e.Result;<br \/>            JsonArray jsonarrays = (JsonArray)JsonArray.Load(new System.IO.StringReader(jsonpoints));<br \/>            ESRI.ArcGIS.Client.Geometry.Polyline line = new ESRI.ArcGIS.Client.Geometry.Polyline()<br \/>            {<br \/>                SpatialReference = Map1.SpatialReference,<br \/>            };<br \/>            ESRI.ArcGIS.Client.Geometry.PointCollection pc = new ESRI.ArcGIS.Client.Geometry.PointCollection();<br \/>            foreach (JsonObject jo in jsonarrays)<br \/>            {<br \/>                pc.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(jo[\"x\"], jo[\"y\"]));<br \/>            }<br \/>            line.Paths.Add(pc);<\/p>\n<p>            \/\/add a graphic<br \/>            Graphic g = new Graphic()<br \/>            {<br \/>                Geometry = line,<br \/>                Symbol = Application.Current.Resources[\"LineSymbol\"] as SimpleLineSymbol,<br \/>            };<br \/>            glayer.Graphics.Add(g);<br \/>}<br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Silverlight\u4e2d\u63d0\u4f9b\u4e86System.Json\u5e93\uff0c\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9JSON\u5b57\u7b26\u4e32\u8fdb\u884c\u89e3\u6790\u3002\u7ed3\u679c\u5982\u56fe\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/4.bp.blogspot.com\/_DD8LUY9p6iU\/SvV0A4dpVHI\/AAAAAAAAAWQ\/dYMaCEDEe3c\/s1600-h\/LR_7.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 252px;\" src=\"http:\/\/4.bp.blogspot.com\/_DD8LUY9p6iU\/SvV0A4dpVHI\/AAAAAAAAAWQ\/dYMaCEDEe3c\/s400\/LR_7.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401350886606328946\" \/><\/a><br \/><span style=\"font-weight: bold; color: rgb(51, 102, 255);font-size:130%;\">3\u3001\u7c7b\u4f3cGoogleMap\u7684\u4ea4\u901a\u6d41\u91cf\u5730\u56fe\uff1a<\/span><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u9996\u5148\u770b\u4e00\u4e0bGoogle\u7684\u4ea4\u901a\u6d41\u91cf\u5730\u56fe\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/SvV0XMjJfAI\/AAAAAAAAAWY\/zlxdRNC6eQQ\/s1600-h\/LR_8.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 302px; height: 362px;\" src=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/SvV0XMjJfAI\/AAAAAAAAAWY\/zlxdRNC6eQQ\/s400\/LR_8.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401351269955238914\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u53ef\u4ee5\u770b\u51fa\uff0c\u4e4b\u6240\u4ee5\u80fd\u4ea7\u751f\u4e0d\u540c\u989c\u8272\u6bb5\uff0c\u9700\u8981\u7684\u6570\u636e\u67093\u4e2a\uff1a\u8be5\u6bb5\u7684\u8d77\u59cb\u548c\u7ec8\u6b62M\u503c\uff0c\u8be5\u6bb5\u7684\u8f66\u6d41\u91cf\u3002\u5047\u8bbe\u6211\u4eec\u83b7\u53d6\u7684\u4e1a\u52a1\u6570\u636e\u8868\uff08EventTable\uff09\u5982\u4e0b\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/2.bp.blogspot.com\/_DD8LUY9p6iU\/SvV0oqXU-yI\/AAAAAAAAAWg\/RG-8RY4efZQ\/s1600-h\/LR_9.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-a\nlign:center;cursor:pointer; cursor:hand;width: 326px; height: 221px;\" src=\"http:\/\/2.bp.blogspot.com\/_DD8LUY9p6iU\/SvV0oqXU-yI\/AAAAAAAAAWg\/RG-8RY4efZQ\/s400\/LR_9.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401351570016500514\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8054\u60f3\u5230\u4e0a\u9762\u7b2c\u4e8c\u4e2a\u5e94\u7528\u573a\u666f\uff0c\u6211\u4eec\u4fbf\u60f3\u53ef\u4ee5\u83b7\u53d6\u6240\u6709\u4ea4\u901a\u6570\u636e\u540e\uff0c\u7528\u5faa\u73af\u7684\u529e\u6cd5\u5c55\u793a\u51fa\u4ea4\u901a\u6d41\u91cf\u5730\u56fe\u3002\u4f46\u8fd9\u91cc\u6709\u4e24\u4e2a\u95ee\u9898\u9700\u8981\u601d\u8003\uff1a1\u3001\u5373\u4f7f\u4f7f\u7528IRouteLocator2.LocateRow\u65b9\u6cd5\uff0c\u670d\u52a1\u5668\u7aef\u6839\u636e\u8d77\u6b62M\u503c\u89e3\u6790\u51fa\u6240\u6709\u7684\u5206\u6bb5\u56fe\u5f62\u9700\u8981\u4e00\u6b21\u5faa\u73af\uff0c\u5ba2\u6237\u7aef\u5c06\u8fd9\u4e9b\u56fe\u5f62\u663e\u793a\u51fa\u6765\u8fd8\u9700\u8981\u4e00\u6b21\u5faa\u73af\uff0c\u8fd9\u6837\u662f\u5426\u5408\u7406\uff1f2\u3001\u7531\u4e8e\u7ed3\u679c\u663e\u793a\u5728\u5ba2\u6237\u7aef\uff0c\u4e0d\u540c\u7528\u6237\u53d1\u51fa\u8bf7\u6c42\u65f6\uff0c\u90fd\u5c06\u91cd\u590d\u4e0a\u9762\u4e24\u4e2a\u5faa\u73af\uff0c\u5982\u4f55\u6539\u8fdb\uff1f<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u89e3\u51b3\u95ee\u9898\u4e00\uff1a\u5728\u7b2c\u4e8c\u8282\u7684Linear Referencing\u5b9e\u73b0\u539f\u7406\u4e2d\uff0c\u63d0\u5230\u4e86RouteEventSource\u7c7b\uff0c\u53ef\u4ee5\u5c06\u5b83\u770b\u4f5c\u662f\u628aRoute FeatureClass\u548cEventTable\u7ec4\u5408\u5728\u4e00\u8d77\u7684\u7ed3\u679c\uff0c\u800c\u8be5\u7c7b\u7ee7\u627f\u81eaFeatureClass\uff0c\u53ef\u5f53\u4f5c\u4e00\u4e2aFeatureClass\u6765\u7528\u3002\u5728ArcMap\u4e2d\u89c2\u5bdf\u751f\u6210\u540e\uff08\u5229\u7528Make Route Event Layer\u5de5\u5177\uff09\u7684RouteEventSource\u5c42\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/4.bp.blogspot.com\/_DD8LUY9p6iU\/SvV04WXfcGI\/AAAAAAAAAWo\/9MChBjC6Xa0\/s1600-h\/LR_10.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 178px;\" src=\"http:\/\/4.bp.blogspot.com\/_DD8LUY9p6iU\/SvV04WXfcGI\/AAAAAAAAAWo\/9MChBjC6Xa0\/s400\/LR_10.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401351839526383714\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e0d\u4ec5\u5305\u542b\u4e86EventTable\u4e2d\u7684\u4e8b\u4ef6\uff0c\u8fd8\u6709\u4e86\u6211\u4eec\u60f3\u8981\u7684Shape\u5b57\u6bb5\uff08\u53ef\u53d6\u51faGeometry\uff09\u3002\u5176\u5b9eShape\u5b57\u6bb5\u4e2d\u7684\u5185\u5bb9\uff0c\u662f\u5229\u7528Dynamic Segmentation\u6280\u672f\u52a8\u6001\u8ba1\u7b97\u51fa\u6765\u7684\u3002\u770b\u5176\u56fe\u5c42\u5c5e\u6027\u4fbf\u77e5\uff0c\u5b83\u662f\u5728\u5185\u5b58\u4e2d\u52a8\u6001\u751f\u6210\u7684\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1EnL_t4I\/AAAAAAAAAWw\/UDORjX_X28g\/s1600-h\/LR_11.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 208px; height: 341px;\" src=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1EnL_t4I\/AAAAAAAAAWw\/UDORjX_X28g\/s400\/LR_11.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401352050200000386\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u6709\u4e86FeatureClass\uff0c\u6211\u4eec\u4fbf\u53ef\u4ee5\u5bf9\u6574\u4e2a\u56fe\u5c42\u8fdb\u884c\u4e00\u6b21\u6e32\u67d3\uff0c\u907f\u514d\u670d\u52a1\u5668\u7aef\u548c\u5ba2\u6237\u7aef\u7684\u4e24\u6b21\u5faa\u73af\u4e86\u3002\u8fd9\u91cc\u8981\u6ce8\u610f\uff0cFeatureClass\u662f\u52a8\u6001\u751f\u6210\u7684\uff0c\u56fe\u5c42\u4fbf\u662f\u52a8\u6001\u6dfb\u52a0\uff0c\u5728\u5730\u56fe\u670d\u52a1\u7684REST\u63a5\u53e3\u4e2d\u65e0\u6cd5\u66b4\u9732\u51fa\u6765\uff0c\u4e5f\u5c31\u4e0d\u80fd\u5229\u7528\u5ba2\u6237\u7aefAPI\u7684\u6e32\u67d3\u6280\u672f\u4e86\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u89e3\u51b3\u95ee\u9898\u4e8c\uff1a\u5229\u7528SOA\u7684\u601d\u60f3\uff0c\u5c06\u4ea4\u901a\u6d41\u91cf\u56fe\u505a\u6210\u4e00\u4e2aTraffic\u670d\u52a1\uff0c\u4e0d\u540c\u7528\u6237\u8bf7\u6c42\u65f6\u52a8\u6001\u6dfb\u52a0\u8be5\u670d\u52a1\u5373\u53ef\u3002\u60f3\u60f3\u8fd9\u4e2a\u670d\u52a1\u5e94\u8be5\u5177\u6709\u7684\u7279\u6027\uff1a\u4e0d\u540c\u65f6\u6bb5\u7684\u4ea4\u901a\u56fe\uff0c\u9700\u8981\u52a8\u6001\u751f\u6210\uff1b\u5982\u679c\u4ea4\u901a\u56fe\u5df2\u7ecf\u751f\u6210\uff0c\u5219\u65e0\u9700\u91cd\u65b0\u751f\u6210\uff0c\u663e\u793a\u5373\u53ef\u3002\u6240\u4ee5\u6211\u4eec\u91c7\u53d6\u6c60\u5316\u65b9\u5f0f\u670d\u52a1\uff08pooled-service\uff09\u7684\u7279\u6027\uff0c\u521a\u597d\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd9\u4e2a\u573a\u666f\u6211\u4eec\u7528Web ADF\u6765\u5b9e\u73b0\uff08\u5ba2\u6237\u7aefAPI\u4e0e\u524d\u4e24\u4e2a\u573a\u666f\u76f8\u540c\uff09\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u9996\u5148\u51c6\u5907\u4e24\u4e2aMap Service\uff1a\u5e95\u56fe\u670d\u52a1\uff1ashaanxi\uff0c\u4ea4\u901a\u6d41\u91cf\u56fe\u670d\u52a1\uff1aShaanxiTraffic\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u540e\u8005\u5728ArcMap\u4e2d\u6253\u5f00\u662f\u8fd9\u6837\u7684\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/3.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1W2UgcLI\/AAAAAAAAAW4\/Xu7OdCw8IyE\/s1600-h\/LR_12.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 334px;\" src=\"http:\/\/3.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1W2UgcLI\/AAAAAAAAAW4\/Xu7OdCw8IyE\/s400\/LR_12.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401352363499876530\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShaanxiTraffic\u670d\u52a1\u9664\u4e86\u52a8\u6001\u751f\u6210\u7684\u4ea4\u901a\u6d41\u91cf\u56fe\u5916\uff0c\u4e0d\u9700\u8981\u5728\u663e\u793a\u4efb\u4f55\u4fe1\u606f\uff0c\u6240\u4ee5\u53d1\u5e03\u65f6\u662f\u7a7a\u767d\u7684\uff1b\u56e0\u4e3a\u52a8\u6001\u751f\u6210\u7684RouteEventSource\u5c06\u4f5c\u4e3a\u56fe\u5c42\u63d2\u5165\u5230\u8fd9\u4e2a\u5730\u56fe\u670d\u52a1\u4e2d\uff0c\u6240\u4ee5Route FeatureClass\u5fc5\u987b\u4e5f\u5728\u8fd9\u4e2amxd\u4e2d\u624d\u884c\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default.aspx\u9875\u9762\u4e2d\u653e\u7f6e\u4e00\u4e2aMapResourceManager\u63a7\u4ef6\u3001\u4e00\u4e2aMap\u63a7\u4ef6\u3001\u4e00\u4e2aCallbackButton\u6309\u94ae\u548c\u4e00\u4e2aGridView\u63a7\u4ef6\u3002\u5148\u770b\u4e00\u4e0b\u7ed3\u679c\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1lrpbLqI\/AAAAAAAAAXA\/WEX8Pq3-DgE\/s1600-h\/LR_13.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 376px;\" src=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1lrpbLqI\/AAAAAAAAAXA\/WEX8Pq3-DgE\/s400\/LR_13.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401352618332860066\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u70b9\u51fb\u6309\u94ae\u540e\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/4.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1wbeX99I\/AAAAAAAAAXI\/vrgqkEq1Ejw\/s1600-h\/LR_14.jpg\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 394px;\" src=\"http:\/\/4.bp.blogspot.com\/_DD8LUY9p6iU\/SvV1wbeX99I\/AAAAAAAAAXI\/vrgqkEq1Ejw\/s400\/LR_14.jpg\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5401352802970105810\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u770b\u4e00\u4e0bDefault.aspx.cs\u4e2d\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\uff1a<br \/><code>protected void CallbackButton1_Clicked(object sender, EventArgs args)<br \/>    {<br \/>        \/\/\u5148\u5224\u65adTraffic\u670d\u52a1\u4e2d\u662f\u5426\u5df2\u7ecf\u4ea7\u751f\u7ed3\u679c<br \/>        if (hasTrafficResult())\/\/Traffic\u670d\u52a1\u4e2d\u5df2\u7ecf\u6709\u7ed3\u679c<br \/>        {<br \/>            \/\/\u5c06\u7ed3\u679c\u63d2\u5165\u5730\u56fe<br \/>            InsertTrafficService();<br \/>        } <br \/>        else\/\/\u670d\u52a1\u4e2d\u8fd8\u6ca1\u6709\u7ed3\u679c<br \/>        {<br \/>            \/\/\u5148\u751f\u6210\u4ea4\u901a\u6d41\u91cf\u7ed3\u679c<br \/>            MakeResult();<br \/>            \/\/\u5c06\u7ed3\u679c\u63d2\u5165\u5730\u56fe<br \/>            InsertTrafficService();<br \/>        }<br \/>        \/\/\u663e\u793aRouteEventSource\u7684\u5c5e\u6027\u8868<br \/>        DisplayAttributeTable();<br \/>    }<br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u601d\u8def\u90fd\u5728\u4ee3\u7801\u4e2d\u3002\u4f9d\u6b21\u6765\u770b\u51e0\u4e2a\u51fd\u6570\uff1a<br \/><code>\/\/\/ <\/p>\n<summary>    \/\/\/ \u5224\u65ad\u6c60\u5316\u7684Traffic\u670d\u52a1\u4e2d\uff0c\u83b7\u53d6\u7684ServerContext\u662f\u5426\u5df2\u7ecf\u4ea7\u751f\u7ed3\u679c<br \/>    \/\/\/ <\/summary>\n<p>    \/\/\/ <returns>true or false<\/returns><br \/>    private bool hasTrafficResult()<br \/>    {<br \/>        ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(\"ArcGISWebServices\", \"yourpassword\", \"\");<br \/>        ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconn = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(\"machinename\", identity);<br \/>        agsconn.Connect();<br \/>        pSOM = agsconn.ServerObjectManager;<br \/>        ESRI.ArcGIS.Server.IServerContext pServerContext = pSOM.CreateServerContext(\"ShaanxiTraffic\", \"MapServer\");<br \/>        ESRI.ArcGIS.Carto.IMapServer2 pMapServer = pServerContext.ServerObject as ESRI.ArcGIS.Carto.IMapServer2;<br \/>        ESRI.ArcGIS.Carto.IMapServerObjects2 pMapServerObjects = pMapServer as ESRI.ArcGIS.Carto.IMapServerObjects2;<br \/>        ESRI.ArcGIS.Carto.IMap pMap = pMapServerObjects.get_Map(pMapServer.DefaultMapName);<br \/>        pServerContext.ReleaseContext();<br \/>        return pMap.LayerCount == 1 ? false : true;<br \/>    }    <br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5bf9\u4e8eShaanxiTraffic\u670d\u52a1\uff0c\u5728\u83b7\u5f97\u7684Server Object\u4e2d\uff0c\u67e5\u770b\u5f53\u524dMap\u7684\u56fe\u5c42\u6570\uff08\u9ed8\u8ba4\u6709\u4e00\u4e2a\u9690\u85cf\u7684Road\u56fe\u5c42\uff09\uff0c\u82e5\u4e3a1\u5219\u8fd8\u672a\u4ea7\u751f\u7ed3\u679c\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e0b\u9762\u662f\u52a8\u6001\u6dfb\u52a0\u670d\u52a1\u7684\u51fd\u6570\uff0c\u6ce8\u610f\u8981\u8bbe\u7f6e\u80cc\u666f\u900f\u660e\uff0c\u4ee5\u4fbf\u80fd\u591f\u770b\u5230\u5e95\u56fe\u670d\u52a1\uff1a<br \/><code>\/\/\/ <\/p>\n<summary>    \/\/\/ \u52a8\u6001\u6dfb\u52a0\u670d\u52a1<br \/>    \/\/\/ <\/summar\ny><br \/>    private void InsertTrafficService()<br \/>    {<br \/>        if (MapResourceManager1.ResourceItems.Count==1)\/\/\u82e5\u5df2\u63d2\u5165\u4ea4\u901a\u6d41\u91cf\u670d\u52a1\uff0c\u5219\u4e0d\u505a\u52a8\u4f5c<br \/>        {<br \/>            MapResourceItem mapResourceItem = new MapResourceItem();<br \/>            GISResourceItemDefinition definition = new GISResourceItemDefinition();<br \/>            mapResourceItem.Name = \"Traffic\";<br \/>            definition.ResourceDefinition = \"Layers@ShaanxiTraffic\";<br \/>            definition.DataSourceDefinition = \"machinename\";<br \/>            definition.DataSourceType = \"ArcGIS Server Local\";<br \/>            mapResourceItem.Parent = MapResourceManager1;<br \/>            mapResourceItem.Definition = definition;<br \/>            ESRI.ArcGIS.ADF.Web.DisplaySettings displaysettings = new ESRI.ArcGIS.ADF.Web.DisplaySettings();<br \/>            displaysettings.Transparency = 0.0F;<br \/>            displaysettings.Visible = true;<br \/>            ESRI.ArcGIS.ADF.Web.ImageDescriptor imagedescriptor = new ESRI.ArcGIS.ADF.Web.ImageDescriptor();<br \/>            imagedescriptor.TransparentBackground = true;<br \/>            imagedescriptor.TransparentColor = System.Drawing.Color.White;<br \/>            displaysettings.ImageDescriptor = imagedescriptor;<br \/>            mapResourceItem.DisplaySettings = displaysettings;<\/p>\n<p>            MapResourceManager1.ResourceItems.Insert(0, mapResourceItem);<br \/>            MapResourceManager1.CreateResource(mapResourceItem);<\/p>\n<p>            if (Map1.ImageBlendingMode == ImageBlendingMode.WebTier)<br \/>            {<br \/>                Map1.Refresh();<br \/>            }<br \/>            else<br \/>            {<br \/>                Map1.RefreshResource(\"Traffic\");<br \/>            }<\/p>\n<p>            CallbackButton1.CallbackResults.CopyFrom(Map1.CallbackResults);<br \/>        }<br \/>    }          <br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MakeResult\u51fd\u6570\u5229\u7528ESRI.ArcGIS.Location\u5e93\u6765\u751f\u6210\u4ea4\u901a\u6d41\u91cf\u56fe\u3002\u7531\u4e8eTraffic\u670d\u52a1\u662f\u6c60\u5316\u670d\u52a1\uff0c\u5f53\u7b2c\u4e00\u4e2a\u7528\u6237\u8bf7\u6c42\uff0c\u751f\u6210\u4ea4\u901a\u6d41\u91cf\u56fe\u540e\uff0c\u8be5\u5b9e\u4f8b\uff08servercontext\uff09\u4f1a\u8fd4\u56de\u670d\u52a1\u5668\u4e0a\u800c\u4e0d\u88ab\u9500\u6bc1\uff0c\u6240\u4ee5\u4e0b\u4e00\u4e2a\u7528\u6237\u518d\u6b21\u8bf7\u6c42\u65f6\u53ef\u4ee5\u76f4\u63a5\u663e\u793a\u3002\u5982\u679c\u8981\u5b9e\u73b0\u5b9e\u65f6\u7684\u4ea4\u901a\u6d41\u91cf\u56fe\uff0c\u5b9a\u65f6\u5728\u670d\u52a1\u5668\u7aef\u91cd\u751fservercontext\uff0c\u5e76\u8bfb\u53d6\u5f53\u524d\u65f6\u6bb5\u7684EventTable\u5373\u53ef\u3002<br \/><code>\/\/\/ <\/p>\n<summary>    \/\/\/ \u751f\u6210\u4ea4\u901a\u6d41\u91cf\u7684\u7ed3\u679c<br \/>    \/\/\/ <\/summary>\n<p>    private void MakeResult()<br \/>    {<br \/>        ESRI.ArcGIS.Server.IServerContext pServerContextTraffic = pSOM.CreateServerContext(\"ShaanxiTraffic\", \"MapServer\");<br \/>        ESRI.ArcGIS.Carto.IMapServer2 pMapServer = pServerContextTraffic.ServerObject as ESRI.ArcGIS.Carto.IMapServer2;<br \/>        ESRI.ArcGIS.Carto.IMapServerObjects2 pMapServerObjects = pMapServer as ESRI.ArcGIS.Carto.IMapServerObjects2;<br \/>        ESRI.ArcGIS.Carto.IMap pMap = pMapServerObjects.get_Map(pMapServer.DefaultMapName);<br \/>        \/\/\u521b\u5efaRouteLocator<br \/>        IFeatureClass pFC = (GetLayerByName(\"Road\",pMap) as IFeatureLayer).FeatureClass;<br \/>        IDataset dS = (IDataset)pFC; \/\/ A polylineM feature class.<br \/>        IName name = dS.FullName;<br \/>        IRouteLocatorName rtLocatorName = pServerContextTraffic.CreateObject(\"esriLocation.RouteMeasureLocatorName\") as IRouteLocatorName;<br \/>        rtLocatorName.RouteFeatureClassName = name;<br \/>rtLocatorName.RouteIDFieldName = \"\u9053\u8def\u7f16\u7801\";<br \/>        rtLocatorName.RouteMeasureUnit = esriUnits.esriUnknownUnits;<br \/>        name = (IName)rtLocatorName;<br \/>        IRouteLocator2 pRtLocator = (IRouteLocator2)name.Open();<\/p>\n<p>        \/\/\u521b\u5efaRouteEventProperties\uff0c\u4e3aRouteEventSource\u505a\u51c6\u5907<br \/>        IRouteEventProperties2 rtProp = pServerContextTraffic.CreateObject(\"esriLocation.RouteMeasureLineProperties\") as IRouteEventProperties2;<br \/>        rtProp.AddErrorField = true;<br \/>        rtProp.ErrorFieldName = \"LOC_ERROR\";<br \/>        rtProp.EventMeasureUnit = esriUnits.esriUnknownUnits;<br \/>        rtProp.EventRouteIDFieldName = \"RouteID\";<br \/>        IRouteMeasureLineProperties rMLineProp = (IRouteMeasureLineProperties)rtProp;<br \/>        rMLineProp.FromMeasureFieldName = \"FromM\";<br \/>        rMLineProp.ToMeasureFieldName = \"ToM\";<\/p>\n<p>        \/\/\u521b\u5efaRouteEventSource<br \/>        ITable eventTable = (pFC.FeatureDataset.Workspace as IFeatureWorkspace).OpenTable(\"lineEventsTable\");<br \/>        IDataset ds = (IDataset)eventTable;<br \/>        IName name2 = ds.FullName;<br \/>        IRouteEventSourceName rtEvtSrcName = pServerContextTraffic.CreateObject(\"esriLocation.RouteEventSourceName\") as IRouteEventSourceName;<br \/>        rtEvtSrcName.EventTableName = name2;<br \/>        rtEvtSrcName.EventProperties = (IRouteEventProperties)rMLineProp;<br \/>        rtEvtSrcName.RouteLocatorName = rtLocatorName;<br \/>        name2 = (IName)rtEvtSrcName;<br \/>        IRouteEventSource rtEvtSrc = (IRouteEventSource)name2.Open();<br \/>        \/\/\u8f6c\u6362\u5230FeatureClass<br \/>    pFC = rtEvtSrc as IFeatureClass;<\/p>\n<p>\/\/\u5c06RouteEventSource\u6dfb\u52a0\u5230\u5730\u56fe\u4e2d\uff0c\u5e76\u8fdb\u884c\u552f\u4e00\u503c\u6e32\u67d3<br \/>        IUniqueValueRenderer pUVR = pServerContextTraffic.CreateObject(\"esriCarto.UniqueValueRenderer\") as IUniqueValueRenderer;<br \/>        pUVR.FieldCount = 1;<br \/>        pUVR.set_Field(0, \"Vehicles\"); <br \/>        pUVR.UseDefaultSymbol = false;<br \/>        IFeatureCursor pFeatureCursor = pFC.Search(null, false);<br \/>        IFeature pFeature = pFeatureCursor.NextFeature();<br \/>        int ifiledindex = pFC.Fields.FindField(\"Vehicles\");\/\/EventTable\u4e2d\u7684\u8f66\u6d41\u91cf\u5b57\u6bb5<br \/>        while (pFeature != null)<br \/>        {<br \/>            ISimpleLineSymbol pSymbol = pServerContextTraffic.CreateObject(\"esriDisplay.SimpleLineSymbol\") as ISimpleLineSymbol;<br \/>            double value = double.Parse(pFeature.get_Value(ifiledindex).ToString());<br \/>            if (value <= 20)<br \/>                pSymbol.Color = ESRI.ArcGIS.ADF.Converter.ToRGBColor(pServerContextTraffic, System.Drawing.Color.FromArgb(71, 196, 69)) as IColor;<br \/>            else if (value > 20 && value <= 50)<br \/>                pSymbol.Color = ESRI.ArcGIS.ADF.Converter.ToRGBColor(pServerContextTraffic, System.Drawing.Color.FromArgb(255, 255, 0)) as IColor;<br \/>            else if (value > 50 && value <= 100)<br \/>                pSymbol.Color = ESRI.ArcGIS.ADF.Converter.ToRGBColor(pServerContextTraffic, System.Drawing.Color.FromArgb(201, 59, 46)) as IColor;<br \/>            else<br \/>                pSymbol.Color = ESRI.ArcGIS.ADF.Converter.ToRGBColor(pServerContextTraffic, System.Drawing.Color.FromArgb(250, 52, 17)) as IColor;<br \/>            pSymbol.Width = 5;<br \/>            pUVR.AddValue(pFeature.get_Value(ifiledindex).ToString(), \"Vehicles\", pSymbol as ISymbol);<br \/>            pFeature = pFeatureCursor.NextFeature();<br \/>        }<br \/>        IFeatureLayer pFL = pServerContextTraffic.CreateObject(\"esriCarto.FeatureLayer\") as IFeatureLayer;<br \/>        pFL.Name = \"RouteEventSource\";<br \/>        pFL.FeatureClass = pFC;<br \/>        (pFL as IGeoFeatureLayer).Renderer = pUVR as IFeatureRenderer;<\/p>\n<p>        pMap.AddLayer(pFL as ILayer);\/\/to the 0 index<br \/>        pMapServerObjects.RefreshServerObjects();<br \/>        pServerContextTraffic.ReleaseContext();<br \/>    }        <br \/><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e00\u70b9\u6ce8\u610f\uff0c\u5728\u4f7f\u7528IServerContext\u63a5\u53e3\u65f6\u8981\u53ca\u65f6\u8fdb\u884c\u91ca\u653e\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u601d\u8003\u4e00\u4e0b\uff1a\u5982\u4f55\u901a\u8fc7Geoprocessing Service\u6765\u5b9e\u73b0\u201c\u4ea4\u901a\u6d41\u91cf\u56fe\u201d\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u73b0\u5728\u6765\u5b9e\u73b0\u4e0a\u9762\u63d0\u5230\u76843\u4e2a\u529f\u80fd\u30021\u3001\u5bf9\u4e8e\u67d0\u6761\u516c\u8def\u4e0a\u7684\u4e00\u70b9\u8fdb\u884cIdentify\u64cd\u4f5c\uff0c\u8981\u6c42\u8fd4\u56de\u8be5\u70b9\u5728\u516c\u8def\u4e0a\u7684\u6869\u53f7\u503c\uff1a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4ee5Silverlight API\u4e3a\u4f8b\u3002\u4e3a\u4e86\u5728\u670d\u52a1\u5668\u7aef\u4f7f\u7528ArcObjects\uff0c\u5728Asp.net\u5de5\u7a0b\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3aLinearRef\u7684Silverlight-Enabled WCF Service\uff0c\u5728LinearRef.svc.cs\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1anamespace RoadDycSeg.Web.WCF{ [ServiceContract(Namespace = &#8220;&#8221;)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class LinearRef { public IRouteLocator2 pRtLocator = null; ESRI.ArcGIS.Server.IServerObjectManager pSOM = null; public ESRI.ArcGIS.Server.IServerContext pServerContext = null; public LinearRef() { ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(&#8220;ArcGISWebServices&#8221;, &#8220;yourpassword&#8221;, &#8220;&#8221;); ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconn = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(&#8220;localhost&#8221;, identity); agsconn.Connect(); pSOM = agsconn.ServerObjectManager; pServerContext = pSOM.CreateServerContext(&#8220;shaanxi&#8221;, &#8220;MapServer&#8221;); ESRI.ArcGIS.Carto.IMapServer2 pMapServer = pServerContext.ServerObject as ESRI.ArcGIS.Carto.IMapServer2; ESRI.ArcGIS.Carto.IMapServerObjects2 pMapServerObjects = pMapServer as ESRI.ArcGIS.Carto.IMapServerObjects2; &hellip; <a href=\"https:\/\/blog.newnaw.com\/?p=18\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ArcGIS\u4e2d\u7684\u7ebf\u6027\u53c2\u8003\/\u52a8\u6001\u5206\u6bb5\u6280\u672f\uff08\u4e09\uff09\u51e0\u4e2aLinear Referencing\u5e94\u7528\u573a\u666f\u5728AGS\u4e2d\u7684\u5b9e\u73b0<\/span> <span class=\"meta-nav\">&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[6,8,9],"_links":{"self":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts\/18"}],"collection":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18"}],"version-history":[{"count":0,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}