def intersection_from_blocks(block_a, block_b, intersection_pt, city, state, zip): pretty_name = pretty_name_from_blocks(block_a, block_b), slug = slug_from_blocks(block_a, block_b) obj, created = Intersection.objects.get_or_create( pretty_name=pretty_name, slug=slug, predir_a=block_a.predir, prefix_a=block_a.prefix, street_a=block_a.street, suffix_a=block_a.suffix, postdir_a=block_a.postdir, predir_b=block_b.predir, prefix_b=block_b.prefix, street_b=block_b.street, suffix_b=block_b.suffix, postdir_b=block_b.postdir, city=city, state=state, zip=zip, # Putting location in "defaults" in case the assumption that # the above args are unique is false. This can happen if 2 streets # intersect more than once, see comment in streets.models.Intersection.Meta # When this happens, the first loaded matching intersection will "win". # ... don't know full implications of changing that assumption # to support multiple such intersections. defaults={'location': intersection_pt}, ) if not created: logger.debug("Already have intersection %s" % obj.pretty_name) return obj
def intersection_from_blocks(block_a, block_b, intersection_pt, city, state, zip): obj = Intersection(pretty_name=pretty_name_from_blocks(block_a, block_b), slug=slug_from_blocks(block_a, block_b), predir_a=block_a.predir, street_a=block_a.street, suffix_a=block_a.suffix, postdir_a=block_a.postdir, predir_b=block_b.predir, street_b=block_b.street, suffix_b=block_b.suffix, postdir_b=block_b.postdir, city=city, state=state, zip=zip, location=intersection_pt) return obj
def intersection_from_blocks(block_a, block_b, intersection_pt, city, state, zip): obj = Intersection( pretty_name=pretty_name_from_blocks(block_a, block_b), slug=slug_from_blocks(block_a, block_b), predir_a=block_a.predir, street_a=block_a.street, suffix_a=block_a.suffix, postdir_a=block_a.postdir, predir_b=block_b.predir, street_b=block_b.street, suffix_b=block_b.suffix, postdir_b=block_b.postdir, city=city, state=state, zip=zip, location=intersection_pt ) return obj