Exemple #1
0
 def loadNetwork(self, network, cost=None, cutoff=None, numToFind=None, searchDist=None, cutoffFld=None, numToFindFld=None, mappings=[]):
   common.progress('creating routing layer')
   if not numToFind:
     numToFind = common.count(self.places)
   self.naLayer = self.makeNALayer(common.checkFile(network), self.NA_LAY, cost, cutoff, numToFind)
   self.cost = cost
   self.placeMapper.addSilentField(cost, float)
   common.progress('calculating places\' network locations')
   self.calculateLocations(network, self.places, searchDist)
   common.progress('loading places to network')
   # create mappings
   toMappingList = common.NET_FIELDS + [(self.NAME_MAP, self.placesIDField, None)]
   for item in mappings:
     toMappingList.append(item + [None])
   fromMappingList = toMappingList[:]
   if cutoffFld:
     fromMappingList.append((self.CUTOFF_PREFIX + cost, cutoffFld, None))
   if numToFindFld:
     fromMappingList.append((self.NUM_TO_FIND_HEADER, numToFindFld, None))
   # load locations
   arcpy.AddLocations_na(self.NA_LAY, self.OD_SUBLAYERS[0], self.places, self.networkMappings(fromMappingList), '', append='clear')
   arcpy.AddLocations_na(self.NA_LAY, self.OD_SUBLAYERS[1], self.places, self.networkMappings(toMappingList), '', append='clear')
   self.routeSublayer = common.sublayer(self.naLayer, self.OUTPUT_SUBLAYER)
   self.linkMapper = conversion.LinkFieldMapper(self.routeSublayer)
   try:
     self.linkMapper.addMapField(self.OUT_COST_PREFIX + cost, cost)
   except conversion.FieldError:
     raise conversion.FieldError, 'cost attribute %s not found in network dataset' % cost
Exemple #2
0
 def loadNetwork(self, network, cost, searchDist, mappings=[]):
   common.progress('calculating places\' network locations')
   network = common.checkFile(network)
   self.calculateLocations(network, self.places, searchDist)
   self.mappings = self.networkMappings(common.NET_FIELDS + mappings)
   if self.speedup:
     self.performSpeedup(network, cost)
   common.progress('preparing routing layer')
   self.naLayer = self.makeRouteLayer(network, self.ROUTE_LAY, cost)
   self.routeSublayer = common.sublayer(self.naLayer, 'Routes')
   # common.debug(common.fieldList(self.routeSublayer))
   self.cost = cost
   self.placeMapper.addSilentField(self.cost, float)
Exemple #3
0
 def loadNetwork(self, network, cost=None, searchDist=None, breaks=[1]):
   common.progress('creating routing layer')
   # if not numToFind:
     # numToFind = common.count(self.places)
   self.naLayer = self.makeNALayer(common.checkFile(network), self.NA_LAY, cost, breaks)
   common.progress('calculating places\' network locations')
   self.calculateLocations(network, self.places, searchDist)
   common.progress('loading places to network')
   # create mappings
   toMappingList = common.NET_FIELDS + [(self.NAME_MAP, self.placesIDField, None)]
   for item in mappings:
     toMappingList.append(item + [None])
   # fromMappingList = toMappingList[:]
   # if cutoffFld:
     # fromMappingList.append((self.CUTOFF_PREFIX + cost, cutoffFld, None))
   # if numToFindFld:
     # fromMappingList.append((self.NUM_TO_FIND_HEADER, numToFindFld, None))
   # load locations
   arcpy.AddLocations_na(self.NA_LAY, self.OD_SUBLAYER, self.places, self.networkMappings(toMappingList), '', append='clear')
   self.outputSublayer = common.sublayer(self.naLayer, self.OUTPUT_SUBLAYER)