com.supermap.analyst.networkanalyst

Class TransportationAnalyst

  • java.lang.Object
    • com.supermap.analyst.networkanalyst.TransportationAnalyst


  • public class TransportationAnalyst
    extends java.lang.Object
    T

    he transportation analyst class. This class is used to provide the path analysis, traveling salesmen analysis, service area analysis, logistics analysis, closest facility and location-allocation analysis, etc.

    The transportation analyst is an important part of network analysis, which is analysis based on the transportation network model. Unlike the facility network model, the transportation network model doesn't has direction. Through you can specify direction for the network edge, the circulation media (the pedestrian or transmission resources) can decide the direction, speed and destination.

    It needs a network dataset. Please refer to the relevant introduction to know how to construct a network dataset. It is needed to use setAnalystSetting method to set the network analysis environment before the analysis.

    You also can read the Network Analysis for more information about network analysis.

    • Constructor Detail

      • TransportationAnalyst

        public TransportationAnalyst()
        Initializes a new instance of the TransportationAnalyst class.
    • Method Detail

      • dispose

        public void dispose()
        Disposes the resources occupied by the object. After calling this method, this object will not be usable.
      • load

        public boolean load()
        Loads the network model.

        Loads data used for transportation analysis, according to the parameters in the TransportationAnalystSetting object. This method can be called after the TransportationAnalystSetting is set. Only when the load method is called, the parameters in the TransportationAnalystSetting object are valid. At this time, the methods in the TransportationAnalyst class can be called to perform facility analysis.

        Note:

        1. The following two situations must recall the Load method to load the network model. This dispose method need to be called for just once before the analysis, there is no needed to call it every time before every analysis.
          • If you modify the TransportationAnalystSetting parameters, you need to reload this method. Otherwise, the modification is invalid.
          • Any modifications to the network dataset, such as the data change, dataset replace, must reload the network model. Otherwise, the analysis may result in error.
        2. If the Load method has been called for loading the network model, before calling the Load method again, the dispose method must be called to dispose the resources, otherwise the load will fail.
        Returns:
        A bool value, whether to load network model.
      • getAnalystSetting

        public TransportationAnalystSetting getAnalystSetting()
        Gets the TransportationAnalystSetting object.

        When making various kinds of transportation analyst with the TransportationAnalyst class, the transportation analyst environment should be set first. The setting of the transportation analyst environment is implemented by the setAnalystSetting() method of the TransportationAnalyst class. For the specific properties, please see the TransportationAnalystSetting class.

        Returns:
        the TransportationAnalystSetting object.
        Default:
        The default value is the default value of the TransportationAnalystSetting object.
      • setAnalystSetting

        public void setAnalystSetting(TransportationAnalystSetting value)
        Sets the TransportationAnalystSetting object.

        When making various kinds of transportation analyst with the TransportationAnalyst class, the transportation analyst environment should be set first. The setting of the transportation analyst environment is implemented by the setAnalystSetting() method of the TransportationAnalyst class. For the specific properties, please see the TransportationAnalystSetting class.

        Parameters:
        value - the TransportationAnalystSetting object.
      • updateEdgeWeight

        public double updateEdgeWeight(int edgeID,
                                       int fromNodeID,
                                       int toNodeID,
                                       java.lang.String weightName,
                                       double weight)
        This method is used to update the edge weight filed with specified parameters.

        This method is used to modify the edge weight of the network model loaded in the memory, which doesn't modify the network dataset.

        This method can update the forward/reverse weight of the edge. The forward weight is the cost from the start node to the end node, whereas the reverse weight is the cost from the end node to the start node. Hence, updates the forward weight if specifying the fromNodeID is the start node ID and the toNodeID is the end node ID of the updated edge in the network dataset; whereas updates the reverse weight if specifying the fromNodeID is the end node ID and the toNodeID is the start node ID.

        Note: The negative weight value denotes the edge is closed to traffic.

        Parameters:
        edgeID - The ID of the edge to be updated.
        fromNodeID - The start node ID of the refreshed edge.
        toNodeID - The end node ID of the refreshed edge.
        weightName - The name of the updated weight field. It is the returned value of the getName() method of the WeightFieldInfo object of the WeightFieldInfos object in the TransportationAnalystSetting class.
        weight - The weight is used to update the old value. It has the same unit with the weight field specified by the weightName property.
        Returns:
        Returns the weight value before updating if successful; otherwise returns -1.7976931348623157e+308.
        Example:
        The following example demonstrates how to update the weight of edge and output the result in the console. The network dataset used by the function below is the dataset whose name is RoadNet in the datasource of changchun.udb under the directory of [Installation\SampleData\changchun\].
         public void UpdateEdgeWeightExample(DatasetVector networkDataset)
             {
                 //Creates an object and a parameter object for the traffic network analysis and does related settings
                 TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
                 TransportationAnalystSetting transportationAnalystSetting = new TransportationAnalystSetting();
                 transportationAnalystSetting.setNetworkDataset ( networkDataset);
                 transportationAnalyst.setAnalystSetting ( transportationAnalystSetting);
        
                 //Loading network model
                 transportationAnalyst.load();
        
                 //Constructs a parameter object for traffic network analysis 
                 TransportationAnalystParameter parameter = new TransportationAnalystParameter();
                 parameter.setNodes ( new int[] { 6901, 6783 });
                 TransportationAnalystResult result1 = transportationAnalyst.findPath(parameter, true);
                 System.out.println("The weight is " + result1.getWeights()[0]);
        
                 //Modifies the weight value of the updated arc
                 transportationAnalyst.updateEdgeWeight(10, 6901, 6783, "Length", 200);
                 TransportationAnalystResult result2 = transportationAnalyst.findPath(parameter, true);
                 System.out.println("The weight is " + result2.getWeights()[0]);
             }
        
         
      • updateTurnNodeWeight

        public double updateTurnNodeWeight(int nodeID,
                                           int fromEdgeID,
                                           int toEdgeID,
                                           java.lang.String turnWeightField,
                                           double weight)
        This method is used to update the weight value of turn node with specified paramters.

        This method is used to modify the turn weight of the network model loaded in the memory, which doesn't modify the turn table.

        It may produce a variety of turns at a turning point. The direction of the turn is determined by the From Edge ID and To Edge ID of the turn node. See the help document for more information.

        Note: The negative turn weight denotes the turn is closed to traffic.

        Parameters:
        nodeID - The ID of the turn node to be updated.
        fromEdgeID - The start node ID of the refreshed edge.
        toEdgeID - The end node ID of the refreshed edge.
        turnWeightField - the turn weight field name.
        weight - The weight is used to update the old value. It has the same unit with the turn weight field specified by the turnWeightField property.
        Returns:
        Returns the weight value before updating if successful; otherwise returns -1.7976931348623157e+308.
      • findPath

        public TransportationAnalystResult findPath(TransportationAnalystParameter parameter,
                                                    boolean hasLeastEdgeCount)
        Optimal path analysis.

        The optimal path analysis is to find the path which has the least impedance to get from one point to another, and the result path will visit the points in the specified order if there are more than two points to visit. "The least impedance" can be defined as the least time, the minimum cost, the best scenery, the best road condition, the least overpasses, the least toll stations or the maximum villages, etc.

        The points to pass for the least-cost path analysis are specified with the parameter of the TransportationAnalystParameter class. The point to pass can be specified with the TransportationAnalystParameter object using two methods.

        1. Using the setNodes property in this class, specifies the points on the optimal path in the form of node ID array in the network dataset, so the points in the analysis are corresponding with network nodes.
        2. Using the setPoints method in the class, specifies the points on the optimal path in the form of coordinate points, so the points in the analysis are corresponding with coordinate points.

        You can specify the other information needed for the optimal path analysis by the TransportationAnalystParameter object, such as barrier points, barrier edges, and whether the analysis result contains the route, path table, and edges/nodes on the optimal path. See the TransportationAnalystParameter class for more information.

        Note: The method is similar with the optimal path analysis findTSPath. They are to find the least cost path that passes all the nodes in the network. The obvious difference between them is the order to visit the nodes in the network.

        • Optimal path analysis: Visits the nodes according to the specified order.
        • Traveling salesmen analysis: Visits the nodes according to the optimal order which may not be the specified order.
        Parameters:
        parameter - The TransportationAnalystParameter object.
        hasLeastEdgeCount - Whether have the least edges or not. True indicates the result path has the least edges. In this case, the result path may not be the shortest path as the number of the edges is not equal to the length of the edge. Takes the following illustration as an example, there are two paths connected AB and the number of edges in the green path is less than the yellow one. If this parameter is set to true, the result path is the green one; and the result path is the yellow one if this parameter is set to false.

        Returns:
        The TransportationAnalystResult object.
        See Also:
        updateEdgeWeight().
      • findTSPPath

        public TransportationAnalystResult findTSPPath(TransportationAnalystParameter parameter,
                                                       boolean isEndNodeAssigned)
        The travelling salesmen analysis.

        The traveling salesmen analysis is to find out the path that passes a specified set of points, with the least (or almost least) impedance. The order of passing those points are not fixed and is decided through the analysis.

        The points passed by the traveling salesmen analysis are specified by the parameter of the TransportationAnalystParameter class. The point to pass can be specified with the TransportationAnalystParameter object using two methods.

        1. Using the setNodes method, specifies the points passed by the traveling salesmen analysis in the form of node ID array in the network dataset, so the points in the analysis are corresponding with the network nodes.
        2. Using the setPoints method, specifies the points passed by the traveling salesmen analysis in the form of coordinate points, so the points in the analysis are corresponding with the coordinate points.

        Note: This method, by default, automatically uses the first point (node or coordinate point) of the points set passed by the traveling salesman analysis as the start point. Moreover, users also can specify the end point by the corresponding isEndNodeAssigned parameter. If you select to specify the end point, then the last point of the specified points set is the end point when the salesman leaves from the first specified point and ultimately arrives the specified end point.

        In addition, if you select to specify the end point and the end point is identical with the start point, i.e., the last passed point is identical with the first point, then the result of the traveling salesmen analysis is a closed path which is that the salesman leaves from the first specified point and ultimately arrives this point.

        Note: When using this method, if the end point is specified by the hasLeastEdgeCount parameter, the first point can be the same with the last point, or a different point; the others point can't be the same, otherwise the analysis will fail; if the end point is not specified, there can not be the same points.

        You can specify the other information needed for the traveling salesmen analysis by the TransportationAnalystParameter object, such as barrier points, barrier edges, and whether the analysis result contains the route, the path table, and the passed edges/nodes. See the TransportationAnalystParameter class for more information.

        Note: The findPath method is similar with the TSP analysis. They are to find the least cost path that passes all the nodes in the network. The obvious difference between them is the order to visit the nodes in the network.

        • Optimal path analysis: Visits the nodes according to the specified order.
        • Traveling salesmen analysis: Visits the nodes according to the optimal order which may not be the specified order.
        Parameters:
        parameter - The TransportationAnalystParameter object.
        isEndNodeAssigned - Whether to specify the end node. Yes if true when the last node in the nodes set is the end node; no if false.
        Returns:
        The TransportationAnalystResult object.
        Example:
        The following example demonstrates how to perform the travelling salesmen analysis. The network dataset used by the function below is the dataset whose name is RoadNet in the datasource of changchun.udb under the directory of [Installation\SampleData\changchun\].
         public void FindTSPPath(DatasetVector networkDataset)
             {
                 //Creates an object for the traffic network analysis and does related settings
                 TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
                 TransportationAnalystSetting Setting = new TransportationAnalystSetting();
                 Setting.setNetworkDataset (networkDataset);
                 transportationAnalyst.setAnalystSetting(Setting);
        
                 //Loading network model
                 transportationAnalyst.load();
        
                 //Constructs and sets a parameter object for traffic network analysis 
                 TransportationAnalystParameter Parameter = new TransportationAnalystParameter();
                 Parameter.setNodes ( new int[] { 2772, 3114, 2878 });
                 Parameter.setNodesReturn ( true);
        
                 //Conduct traveling salesman analysis
                 TransportationAnalystResult Result = transportationAnalyst.findTSPPath(Parameter, false);
        
                 //Cyclically output pathways node ID
                 for (int i = 0; i < Result.getNodes().length; i++)
                 {
                     for (int j = i; j < Result.getNodes()[i].length; j++)
                     {
                         System.out.println(Result.getNodes()[i][j]);
                     }
                 }
             }
         
      • findClosestFacility

        public TransportationAnalystResult findClosestFacility(TransportationAnalystParameter parameter,
                                                               int eventID,
                                                               int facilityCount,
                                                               boolean isFromEvent,
                                                               double maxWeight)
        Conducts the closest facility analysis according to the given parameters, and the event point is the node ID.

        The closest facility analysis is to specify an event or a set of facilities and find out one or more facilities that are able to be reached with the minimum cost from the event. The result is the optimal path from the event to the facility (or from the facility to the event).

        For detailed information about closest facility analysis, see the other overload method findClosestFacility. That method specify the event points with coordinate points.

        Parameters:
        parameter - The TransportationAnalystParameter object.
        eventID - event node ID
        facilityCount - The count of the facilities.
        isFromEvent - Whether to search from the events to the facilities.
        maxWeight - Searching radius. The unit is the same as the weight filed set in the NetworkAnalystSetting class. If searching the whole network, this value is set 0.
        Returns:
        The TransportationAnalystResult object.
        Example:
        The code below shows how to do the analysis. The network dataset and point dataset is RoadNet the network dataset and Hospital the point dataset which are from changchun.udb from \SampleData\changchun.
         public void FindClosesetFacilityExample(DatasetVector networkDataset,DatasetVector pointDataset)
             {
                 //Creates a parameter object for the traffic network analysis and does related settings
                 TransportationAnalystSetting transportationAnalystSetting = new TransportationAnalystSetting();
                 transportationAnalystSetting.setNetworkDataset(networkDataset);
                 transportationAnalystSetting.setNodeIDField ( "SmNodeID");
                 transportationAnalystSetting.setEdgeIDField ( "SmID");
                 transportationAnalystSetting.setTolerance ( 89.00);
        
                 //Sets the weight information
                 WeightFieldInfos weightInfos = new WeightFieldInfos();
                 WeightFieldInfo weightInfo = new WeightFieldInfo();
                 weightInfo.setFTWeightField ( "SmLength");
                 weightInfo.setTFWeightField ( "Smlength");
                 weightInfo.setName ( "Name");
                 weightInfos.add(weightInfo);
                 transportationAnalystSetting.setWeightFieldInfos (weightInfos);
        
                 //Creates an object for the traffic network analysis, sets the analysis environment object and loads the network model
                 TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
                 transportationAnalyst.setAnalystSetting (transportationAnalystSetting);
                 transportationAnalyst.load();
        
                 //Gets the record set from facility point dataset directly.
                 Recordset recordset = pointDataset.getRecordset(false, CursorType.DYNAMIC);
        
                 //The returned ID of hospital is assigned to the ID of pathway node.
                 int[] nodes = new int[recordset.getRecordCount()];
                 for (int i = 0; i < recordset.getRecordCount(); i++)
                 {
                     nodes[i] = i;
                 }
        
                 //Constructs a parameter object for traffic network analysis and does related settings.
                 TransportationAnalystParameter parameter = new TransportationAnalystParameter();
                 parameter.setNodes (nodes);
                 parameter.setWeightName (weightInfo.getName());
                 parameter.setEdgesReturn (true);
                 parameter.setNodesReturn (true);
                 parameter.setRoutesReturn (true);
        
                 //Doing the closest facility analysis
                 int eventPoint = 100;
                 int facilityCount = 3;
                 double maxWeight = 0.0;
                 TransportationAnalystResult result = transportationAnalyst.findClosestFacility(parameter, eventPoint, facilityCount, true, maxWeight);
             }
         
      • findClosestFacility

        public TransportationAnalystResult findClosestFacility(TransportationAnalystParameter parameter,
                                                               Point2D eventPoint,
                                                               int facilityCount,
                                                               boolean isFromEvent,
                                                               double maxWeight)
        Conducts the closest facility analysis according to the given parameters, and the event point is the coordinate point.

        The closest facility analysis is to specify an event or a set of facilities and find out one or more facilities that are able to be reached with the minimum cost from the event. The result is the optimal path from the event to the facility (or from the facility to the event).

        Facilities and events are the basic features for closest facility analysis. Facilities are schools, supermarkets, gas station, etc. that provide services. Event points are the event locations that need the service of the facilities.

        For instance, an accident happened at certain location. it is needed to query the 3 hospitals that can be reached within 10 minutes, the hospitals that can be reached with more than 10 minutes will not be considered. In this example, the event location is the event point and the nearby hospitals are the facilities.

        There are two ways to specify the event points, using the coordinate points or the IDs of the nodes in the network dataset (view the network vertexes as the event points). In this method, the event points are specified with coordinate points. In the other override method , the event points are specified with vertex ID.

        The facilities are specified with the parameter of the TransportationAnalystParameter class. The point to pass can be specified with the TransportationAnalystParameter object using two methods.

        1. Using the setNodes method in this class, specify the facilities in the form of ID array in the network dataset, so the facilities in the analysis is corresponding with network nodes.
        2. 2. Using the setPoints method in the class, specify the facilities in the form of coordinate points, so the facilities in the analysis is corresponding with network nodes.

        Closest facility is a kind of path analysis, so, you can set nodes and edges as barriers.

        You can specify other information needed for least-cost path with the TransportationAnalystParameter object, such as the weight information, whether the analysis result contains route, path table, and the arcs, nodes passed by. See the TransportationAnalystParameter class for more information.

        Parameters:
        parameter - The TransportationAnalystParameter object.
        eventPoint - event point coordinates.
        facilityCount - The count of the facilities.
        isFromEvent - Whether to search from the events to the facilities.
        maxWeight - Searching radius. The unit is the same as the weight filed set in the NetworkAnalystSetting class. If searching the whole network, this value is set 0.
        Returns:
        The TransportationAnalystResult object.
        Example:
        The code below shows how to do the analysis. The network dataset and point dataset is RoadNet the network dataset and Hospital the point dataset which are from Changchun.udb from \SampleData\City\.
         public void FindClosesetFacilityExample(DatasetVector networkDataset,DatasetVector pointDataset)
             {
                 //Creates a parameter object for the traffic network analysis, and does the related settings
                 TransportationAnalystSetting transportationAnalystSetting = new TransportationAnalystSetting();
                 transportationAnalystSetting.setNetworkDataset(networkDataset);
                 transportationAnalystSetting.setNodeIDField ("SmNodeID");
                 transportationAnalystSetting.setEdgeIDField ("SmID");
                 transportationAnalystSetting.setTolerance ( 89.00);
        
                 //Sets the weight information
                 WeightFieldInfos weightInfos = new WeightFieldInfos();
                 WeightFieldInfo weightInfo = new WeightFieldInfo();
                 weightInfo.setFTWeightField ("SmLength");
                 weightInfo.setTFWeightField ("Smlength");
                 weightInfo.setName ("Name");
                 weightInfos.add(weightInfo);
                 transportationAnalystSetting.setWeightFieldInfos (weightInfos);
        
                 //Creates an object for the traffic network analysis and sets a analysis environment object
                 TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
                 transportationAnalyst.setAnalystSetting (transportationAnalystSetting);
        
                 //Loading the network model
                 transportationAnalyst.load();
        
                 //Gets the record set from facility point dataset directly.
                 Recordset recordset = pointDataset.getRecordset(false, CursorType.DYNAMIC);
        
                 //Traverse each record in the facility point record set to get the geometric object
                 //Gets the coordinate x, y of the point geometric object to construct point object, and adds it into the object of point collection
                 Point2Ds points = new Point2Ds();
                 for (int i = 0; i < recordset.getRecordCount(); i++)
                 {
                     GeoPoint geoPoint = (GeoPoint)recordset.getGeometry();
                     Point2D point = new Point2D(geoPoint.getX(), geoPoint.getY());
                     points.add(point);
                     recordset.moveNext();
                 }
                 //Constructs a traffic network analysis parameter object
                 TransportationAnalystParameter parameter = new TransportationAnalystParameter();
                 parameter.setPoints ( points);
                 parameter.setWeightName (weightInfo.getName());
                 parameter.setEdgesReturn ( true);
                 parameter.setNodesReturn ( true);
                 parameter.setRoutesReturn (true);
        
                 //Doing the closest facility analysis
                 Point2D eventPoint = new Point2D(3534, 3820);
                 int facilityCount = 3;
                 double maxWeight = 0.0;
                 TransportationAnalystResult result = transportationAnalyst.findClosestFacility(parameter, eventPoint, facilityCount, true, maxWeight);
             }
      • findMTSPPath

        public TransportationAnalystResult findMTSPPath(TransportationAnalystParameter parameter,
                                                        int[] centerNodes,
                                                        boolean hasLeastTotalCost)
        The method is used for the MTSP (logistics) which the delivery centers are the node ID array.

        The multiple traveling salesman analysis is to find the shortest delivery route from M points of origins to N points of destinations (M and N are integers greater than 0). The MTSP of SuperMap Desktop .NET is used for finding the least cost order and route of the distribution.

        Please refers to another method findMTSPPath for the detailed introduction. The FindMTSPPath method specifies the delivery centers with coordinate points, whereas this method specifies the delivery centers with the node ID array.

        Parameters:
        parameter - The TransportationAnalystParameter object.
        centerNodes - The ID array of delivery center nodes in network.
        hasLeastTotalCost - Whether to use the minimal total cost schema. There are two schemas can be selected in performing Logistics. One is the minimal total cost, in this case, it is possible that some delivery centers may cost more and others cost less. Another is the optimal in each delivery center, but the total cost may not be the minimum.
        Returns:
        The TransportationAnalystResult object.
      • findMTSPPath

        public TransportationAnalystResult findMTSPPath(TransportationAnalystParameter parameter,
                                                        Point2Ds centerPoints,
                                                        boolean hasLeastTotalCost)
        The method is used to analyze Multiple TSP which the delivery center points are a series of coordinates.

        The multiple traveling salesman analysis is to find the shortest delivery route from M points of origins to N points of destinations (M and N are integers greater than 0). The MTSP of SuperMap Desktop .NET is used for finding the least cost order and route of the distribution.

        There are two ways to specify the delivery centers: One is to specify with the coordinate points; the other one is to specify with node ID array. The delivery centers of this method need to be specified with the coordinate points (the centerPoints parameter), so the corresponding coordinate points are the centers. For the other reload method , the centers are specified with the node ID array, and now the corresponding nodes are considered as the centers.

        The destinations are specified with the parameter of the TransportationAnalystParameter class. The destinations can be specified with TransportationAnalystParameter the object using two methods.

        1. Using the setNodes method, specifies the destinations in the form of ID array in the network dataset, so the destinations in the analysis are corresponding with the network nodes.
        2. Using the setPoints method, specifies the destinations in the form of coordinate points, so the destinations in the analysis are corresponding with the network nodes.

        You can specify the other information needed for the optimal path analysis by the TransportationAnalystParameter object, such as barrier points, barrier edges, and whether the analysis result contains the route, path table, and edges/nodes on the optimal path. See the TransportationAnalystParameter class for more information.

        The results of MTSP include the destinations of each center, and the order to pass the destinations and the corresponding routes so that the delivery cost of the center is minimum or the total cost of all the centers is minimum. Moreover, the center will ultimately return to the center after finishing the task for its responsible destinations.

        For example: there are 50 newspaper retailers (delivery destinations) and 4 newspaper suppliers (delivery centers) now. You need to search for the optimal paths of these 4 suppliers to deliver newspapers to the newspaper retailers. This is a MTSP problem.

        The following figure shows the result to deliver the newspapers, where the bigger red dots represent 4 newspaper suppliers (delivery centers), and the other smaller dots represent newspaper retailers (delivery destinations). Each color represents the delivery scheme of a delivery center including the delivery destinations, delivery order and delivery path.

        The figure below shows the delivery scheme of the No. 2 center within the rectangle box of the figure above. The blue and numbered small dots are delivery destinations that the No. 2 delivery center is responsible for (there are 18 in total). The No. 2 delivery center will deliver newspapers one by one according to the numbered order on the delivery destinations. It delivers to the No. 1 newspaper retailer first, and then delivers to the No. 2 newspaper retailer, and so on. After completing the delivery along the blue path derived from the analysis, it goes back to the delivery center.

        Note: The objective of MTSP is to find the least total cost scheme or the scheme that the cost of each center is minimum. Hence, some centers may not be involved in the delivery task.

        Parameters:
        parameter - The TransportationAnalystParameter object.
        centerPoints - A series of coordinates of delivery center points, which type is Point2Ds.
        hasLeastTotalCost - Whether to use the minimal total cost schema. There are two schemas can be selected in performing Logistics. One is the minimal total cost, in this case, it is possible that some delivery centers may cost more and others cost less. Another is the optimal in each delivery center, but the total cost may not be the minimum.
        Returns:
        The TransportationAnalystResult object.
        Example:
        The following example demonstrates how to perform the travelling salesmen analysis. The network dataset used by the function below is the dataset whose name is RoadNet in the datasource of changchun.udb under the directory of [Installation\SampleData\changchun\].
         public void FindMTSPPath1(DatasetVector networkDataset)
             {
                 //Creates an object and an parameter object for traffic network analysis.
                 TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
                 TransportationAnalystSetting transportationAnalystSetting = new TransportationAnalystSetting();
                 transportationAnalystSetting.setNetworkDataset ( networkDataset);
                 transportationAnalyst.setAnalystSetting ( transportationAnalystSetting);
        
                 //Loading network model
                 transportationAnalyst.load();
        
                 //Constructs and sets a traffic network analysis parameter object
                 TransportationAnalystParameter parameter = new TransportationAnalystParameter();
                 Point2Ds pt2Ds=new Point2Ds(new Point2D[] { new Point2D(14, 50),new Point2D(30, 28),new Point2D(40,50) });
                 parameter.setPoints (pt2Ds);
                 parameter.setPathGuidesReturn ( true);
                 parameter.setStopIndexesReturn ( true);
                 parameter.setWeightName("Length");
        
                 //Sets the distribution center point coordinate string
                 Point2D[] point2D = { new Point2D(10, 20), new Point2D(30, 40), new Point2D(50, 60) };
                 Point2Ds point2Ds = new Point2Ds(point2D);
                 new Point2Ds(new Point2D[] { new Point2D(14, 50),new Point2D(30, 28),new Point2D(40,50) });
        
        
                 //Conduct multiple travelling salesman analysis and return results
                 TransportationAnalystResult Result = transportationAnalyst.findMTSPPath(parameter, point2Ds, false);
             }
        
         
      • findServiceArea

        public ServiceAreaResult findServiceArea(TransportationAnalystParameter parameter,
                                                 double[] weights,
                                                 boolean isFromCenter,
                                                 boolean isCenterMutuallyExclusive)
        The service area analysis.

        The service area is the area that within a certain impedance taking specified point as the center and containing all the accessible edges. The service area analysis is to find the service range for a specified location (center point) according to a specified impedance value (service radius). The impedance can be time, distance or any other cost. For example, when you want to find the 30-minute service area for a specified point, within the result service area, it takes less than 30 minutes from any point to the specified point.

        The results of the service area analysis cover all the routes and areas that the service center points can reach. The route is the path along the network edges from the service center point according to the rule that the impedance value is less than or equal to a specified service radius. The service area is a polygon area that covers all the routes of the center point according to a specified algorithm. In the figure below, the red point denotes the service center point. Multi-colored polygons are the service areas, and the routes are denoted by the corresponding color of the service area.

        When calling this method, you need to specify a TransportationAnalystParameter object to set the parameters for a specified service area, including the location of the service area, weight (impedance) information, barrier information, whether to return the path table, route, and edges/nodes set, etc.

        Service center

        There are two ways to specify the location of the specified service area by the TransportationAnalystParameter object.

        1. Using the setNodes() method, specifies the service center points in the form of node ID array in the network dataset, so the center points in the analysis are corresponding with the network nodes.
        2. Using the setPoints() method, specifies the center points in the form of coordinate points, so the points in the analysis are corresponding with coordinate points.

        Whether to analyze from the center

        It represents the relation mode between the service center and the demand site. Analyzing from a center is that a service center provides the demand sites with services; whereas analyzing from a demand site is that a demand site gets services from the service center initiatively. For example, a milk station delivers milk to various settlements. If making the service area analysis on this milk station to see the service range, you must choose the mode of analyzing from centers. Another example, if making the service area analysis on a school, you must choose the mode of analyzing from demand sites, because students going to school is an initiative behavior.

        Exclusive service area

        If two or more service areas intersect, you can do the mutually exclusive process for them. After the mutually exclusive process, these service areas will not intersect. In the figure below, the left/right figure is before/after the mutually exclusive process respectively.

        Parameters:
        parameter - The TransportationAnalystParameter object.
        weights - The radius array of the service area. The length of the array should be consistent with the number of the specified service center points. The radius has the same unit with the from-to weight field and the to-from weight field of the specified weight information.
        isFromCenter - Whether analyzing from the centers.
        isCenterMutuallyExclusive - Whether to perform the mutually exclusive process. Yes if True; no if false.
        Returns:
        The ServiceAreaResult object.
        Example:
        The following example demonstrates how to perform the service area analysis. The network dataset used by the function below is the dataset whose name is RoadNet in the datasource of changchun.udb under the directory of [Installation\SampleData\changchun\].
         public void FindServiceArea(DatasetVector networkDataset)
             {
                 //Creates an object and an parameter object for traffic network analysis.
                 TransportationAnalystSetting Setting = new TransportationAnalystSetting();
                 Setting.setNetworkDataset (networkDataset);
                 TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
                 transportationAnalyst.setAnalystSetting (Setting);
        
                 //Loading network model
                 transportationAnalyst.load();
        
                 //Constructs and sets a traffic network analysis parameter object
                 TransportationAnalystParameter Parameter = new TransportationAnalystParameter();
                 Parameter.setNodes (new int[] { 3, 40 });
                 Parameter.setRoutesReturn(true);
        
                 //Doing the network analysis to find the service area
                 ServiceAreaResult serviceAreaResult = transportationAnalyst.findServiceArea(Parameter, new double[] { 28.0, 50.0 }, false, false);
        
             }
        
         
      • findLocation

        public LocationAnalystResult findLocation(LocationAnalystParameter parameter)
        Analyzes the location with the specified LocationAnalystParameter object.

        The location-allocation analysis is to determine the optimal location of one facility or multiple facilities, so that the facilities can provide the demand-side with services or goods with a most economical and effective method. The location-allocation not only is a location process, but also needs to allocate the demands of the demand-side to the corresponding service areas. Therefore, it is called location-allocation.

        • Supply center and demand-side

          Supply center: The center point that are the facilities which supply the resources and services. Corresponding to the network nodes, the related information of the resources supply centers includes the maximum impedance value, the resources supply centers' types, the nodes ID of resources supply centers in the network, etc.

          Demand-side: It is generally the location that the supply center provides the services and resources for, which is also corresponding to the network node.

          Maximum Impedance is used to restrict the cost from the demand point to the center. If the cost from the demand point, including edge and node, to the center is higher than the maximum impedance, the demand point is filtered out. The maximum impedance can be edited.

          Types of resource supply centers: none-centers, fixed centers and optional centers. Fixed centers are service facilities that have existed and have been constructed in the network (which perform the role of resource supply). Optional centers are resource supply centers that can construct service facilities, that is, service facilities to be constructed will locate in these optional centers; non-centers are not used in the analysis. It may not permit to construct this facility or other facilities that may have existed in reality.

          All the demand points used during the analysis process are the network nodes, which mean that all the network nodes as the resources demand points except the network nodes according to each types of the center points are involved in the analysis of the location-allocation. If eliminate part of the nodes , they can be set as barrier points.

        • Whether to allocate resources from the supply center.

          Location-Allocation can select to deliver the resources derived from the centers, or not from:

        • The example of allocating from centers (from the supply to the demand) :
        • The electric energy is generated from the power station, and transmitted to clients by the electric network. Here, the power station is the center in the network model, because it can provide electricity supply. The electricity clients distribute along electric network lines (edges in the network model), and they produce "demands". In this situation, the resource is transmitted from the supplier to the demand-side by the network so as to implement the resource allocation.

        • The example of not allocating from centers (from the demand to the supply):
        • The relation between the school and the students also constitutes a kind of supply-and-demand allocation relation in the network. The school is the resource supplier, and it is responsible for providing school-age children with places to go to school. School-age children are demand-sides of the resource. They demand to enter the school. School-age children as demand-sides distribute along the street network, and they generate demands for the resource of the school as the supplier--student places.

      • Application Instance
      • Currently, there are 3 primary schools in a region. It will establish 3 new primary schools in this region according to the demand. Selecting 9 locations as the optional locations, we will select 3 optimal locations for building the schools. As shown in the figure 1, the existed 3 schools are the fixed centers; 7 optional locations are the optional centers. The conditions to be met for building a new school: It takes the residents within the residential area no more than 30 minutes to walk to the school. The location-allocation analysis will give the optimal locations, and display the service area of each school including the existed 3 schools. As shown in figure 2, the No. 5, No. 6 and No. 8 optional centers are ultimately selected as the optimal locations to build the schools.

        Note: all the network nodes of the network datasets in the following two maps can be seen as the settlements and all of them can be involved in the location-allocation analysis, and the number of the residents in the settlements is the needed services number of these settlements.

      The parameter of the LocationAnalystParameter class is used to specify the supply center, the type and maximum impedance of the center, whether to deliver the resources from the center, and the number of the expected supply centers, etc. For more information, see the LocationAnalystParameter class.

Parameters:
parameter - The location-allocation parameter object.
Returns:
The location-allocation result object.
Example:
The following example demonstrates how to perform the location-allocation analysis. The network dataset used by the function below is the dataset whose name is RoadNet in the datasource of changchun.udb under the directory of [Installation\SampleData\changchun\].
 public void FindLocationExample(DatasetVector networkDataset)
     {
         //Constructs an environment setting object for traffic network analysis
         TransportationAnalystSetting setting = new TransportationAnalystSetting();
         setting.setNetworkDataset (networkDataset);
         setting.setEdgeIDField ("SmID");
         setting.setNodeIDField ("SmNodeID");
         setting.setTolerance (89.00);

         //Sets the weight information
         WeightFieldInfos weightFieldInfos = new WeightFieldInfos();
         WeightFieldInfo weightFieldInfo = new WeightFieldInfo();
         weightFieldInfo.setFTWeightField ("SmLength");
         weightFieldInfo.setTFWeightField ("SmLength");
         weightFieldInfo.setName ("Length");
         weightFieldInfos.add(weightFieldInfo);
         setting.setWeightFieldInfos (weightFieldInfos);
         setting.setFNodeIDField ("SmFNode");
         setting.setTNodeIDField ("SmTNode");

         //Constructs an object for traffic network analysis, loads the environment setting object
         TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
         transportationAnalyst.setAnalystSetting (setting);
         transportationAnalyst.load();

         //Constructs the traffic network analysis parameter
         LocationAnalystParameter parameter = new LocationAnalystParameter();

         //Constructs five resource supply center objects
         int[] id = { 3534, 1190, 1384, 4503, 5416 };
         for (int i = 0; i < id.length; i++)
         {
             SupplyCenter supplyCenter = new SupplyCenter();
             supplyCenter.setID (id[i]);
             supplyCenter.setMaxWeight( 7000);
             supplyCenter.setType (SupplyCenterType.OPTIONALCENTER);
             // Adds the objects to collection
             parameter.getSupplyCenters().add(supplyCenter);
         }
         parameter.setFromCenter ( true);
         parameter.setExpectedSupplyCenterCount (5);
         parameter.setWeightName (weightFieldInfo.getName());

         //Perform site analysis and return the analysis results
         LocationAnalystResult result = transportationAnalyst.findLocation(parameter);

         //Returns the related information
         DemandResult[] demandResult = result.getDemandResults();
         System.out.println(demandResult[1].getID());
         System.out.println(demandResult[1].getSupplyCenterID());
     }
 
  • computeWeightMatrix

    public double[][] computeWeightMatrix(TransportationAnalystParameter parameter)
    Calculates the cost matrix of the specified point. The matrix is a 2D double array used to store the least cost between any two points.

    This method can be used to calculate the cost matrix among the specified nodes (coordinate points). It can use the setPoints method of the setPoints object to specify the nodes of the cost matrix to be computed, and use the setPoints method to specify the coordinate point to be computed. Note that the two are mutually exclusive, if you set them simultaneously, then only the last setting is valid before the analysis. For example, you specify the nodes and then the coordinate points, then it will only analyze the coordinate point.

    This method will calculate the least cost between two points, which is the cost of the optimal path. The settings of the barrier points or barrier edges are valid in this method. It has identical cost in the result with the findPath method.

    The cost matrix is a 2D array with the same rows and columns. The index of the elements are identical with the index of the specified points to be calculated. For example, The value of the element [1,2] is the least cost from No. 1 point in the points' index to the No. 2 point in the index. Note that the result includes the cost form a point to itself, and the value is 0.

    Parameters:
    parameter - The specified TransportationAnalystParameter object.
    Returns:
    Returns a matrix which contains the weight information between every two points or nodes.
    Example:
    The code below shows how to get the cost matrix according to the input TransportationAnalystParameter. The network dataset used by the function below is the dataset whose name is RoadNet in the datasource of changchun.udb under the directory of [Installation\SampleData\changchun\].
     public void ComputeWeightMatrixExample(DatasetVector networkDataset)
         {
             //Constructs a traffic network analysis parameter object
             TransportationAnalystSetting transportationAnalystSetting = new TransportationAnalystSetting();
             transportationAnalystSetting.setNetworkDataset(networkDataset);
             transportationAnalystSetting.setNodeIDField ("SmNodeID");
             transportationAnalystSetting.setEdgeIDField ("SmID");
             transportationAnalystSetting.setTolerance (89.00);
    
             //Sets the weight information
             WeightFieldInfos weightInfos = new WeightFieldInfos();
             WeightFieldInfo weightInfo = new WeightFieldInfo();
             weightInfo.setFTWeightField ("SmLength");
             weightInfo.setTFWeightField ("Smlength");
             weightInfo.setName ("Name");
             weightInfos.add(weightInfo);
             transportationAnalystSetting.setWeightFieldInfos (weightInfos);
    
             //Creates a traffic network analysis object and sets a setting analysis environment object
             TransportationAnalyst transportationAnalyst = new TransportationAnalyst();
             transportationAnalyst.setAnalystSetting (transportationAnalystSetting);
    
             //Loads network model
             transportationAnalyst.load();
    
             //Constructs a parameter setting objects for traffic network analysis, sets the weight name, node ID array
             TransportationAnalystParameter parameter = new TransportationAnalystParameter();
             parameter.setWeightName(weightInfo.getName());
             int[] nodes = { 3534, 3000, 3820 };
             parameter.setNodes (nodes);
    
             //Create a cost matrix analysis, returns a two-dimensional array
             double[][] matrix = transportationAnalyst.computeWeightMatrix(parameter);
    
             //Releases resources
             workspace.dispose();
         }
  • check

    public TransportationAnalystCheckResult check()
    Checks the transportation network dataset and the turn table, and return the result object.

    This method will check the network dataset and the turn table, and offer error information for user, which is convenient them to modify the data. So it avoids the analysis errors because of the data error.

    Note:This method will be called after setting the transportation analyst environment (setAnalystSetting). But you needn't the method of loading network model Load(setAnalystSetting method).

    In the TransportationAnalystSetting(TransportationAnalystSetting), there isn't the specified turn table, it won't check the turn table.

    This method returns a TransportationAnalystCheckResult object. You can get the arc error information and node error information with the getArcErrorInfos method and the getNodeErrorInfos method of this object. You can get the turn table error information with the getTurnErrorInfos method. The error information are stored in three dictionaries, in which the keys represent the SMID of the nodes or arcs and the values represent the error types. The error types are represented by numbers, the meanings are as the following.

    1. The wrong result types of network datasets are as shown below:
    2. The wrong result types of turn tables are as shown below:
    Returns:
    The result.
  • createModel

    public boolean createModel(java.lang.String filePath)
    Creates the memory file.

    Calls the interface after calling load(), which can generate the memory file of relevant load().

    Parameters:
    filePath - Creates the directory of the memory file. The extension is '.snm'.
    Returns:
    Whether it creates the memory file successfully.
  • loadModel

    public boolean loadModel(java.lang.String filePath,
                             DatasetVector networkDataset)
    Loads the memory file.

    The network dataset to generate files should be the same with the passed one by the interface, otherwise it will fail to load.

    Parameters:
    filePath - The memory file path.
    networkDataset - The network dataset to use.
    Returns:
    Whether the network module is loaded successfully.