Exemplo n.º 1
0
    def set_location(self, ni):
        """
        Calculates and sets the location for this NewsItem from the cnn_list.
        """
        geom_set = []
        for cnn in simplejson.loads(ni.attributes['json'])['cnn_list']:
            try:
                geom = SfStreet.objects.get(cnn=cnn).location
            except SfStreet.DoesNotExist:
                pass
            else:
                geom_set.append(geom)

        geom = line_merge(make_geomcoll(geom_set))
        if not geom.empty:
            ni.location = geom
        else:
            self.logger.debug('got an empty geometry from list of geoms: %r' % geom_set)
Exemplo n.º 2
0
    def set_location(self, ni):
        """
        Calculates and sets the location for this NewsItem from the cnn_list.
        """
        geom_set = []
        for cnn in simplejson.loads(ni.attributes['json'])['cnn_list']:
            try:
                geom = SfStreet.objects.get(cnn=cnn).location
            except SfStreet.DoesNotExist:
                pass
            else:
                geom_set.append(geom)

        geom = line_merge(make_geomcoll(geom_set))
        if not geom.empty:
            ni.location = geom
        else:
            self.logger.debug('got an empty geometry from list of geoms: %r' %
                              geom_set)
Exemplo n.º 3
0
    def set_location(self, ni):
        """
        Calculates and sets the location for this NewsItem from the cnn_list.
        """
        geom_set = []

        location_details = simplejson.loads(ni.attributes['location_details'])

        for cnn in location_details['cnn_list']:
            try:
                geom = SfStreet.objects.get(cnn=cnn).location
            except SfStreet.DoesNotExist:
                pass
            else:
                geom_set.append(geom)

        for detail in location_details['details']:
            # Try using the cnn first, but for some reason the sf streets db
            # doesn't have *every* cnn.
            if detail.has_key('cnn'):
                try:
                    geom = SfStreet.objects.get(cnn=detail['cnn']).location
                except SfStreet.DoesNotExist:
                    pass
                else:
                    geom_set.append(geom)

            # If the cnn wasn't found, and this is an itersection, try getting
            # the location by cross streets.
            else:
                geom = SfStreet.objects.get_intersection(
                    detail['cross_street_1'],
                    detail['cross_street_2']
                )
                if geom:
                    geom_set.append(geom)

        geom = line_merge(make_geomcoll(geom_set))
        if not geom.empty:
            ni.location = geom
        else:
            self.logger.debug('got an empty geometry from list of geoms: %r' % geom_set)
Exemplo n.º 4
0
    def set_location(self, ni):
        """
        Calculates and sets the location for this NewsItem from the cnn_list.
        """
        geom_set = []

        location_details = simplejson.loads(ni.attributes['location_details'])

        for cnn in location_details['cnn_list']:
            try:
                geom = SfStreet.objects.get(cnn=cnn).location
            except SfStreet.DoesNotExist:
                pass
            else:
                geom_set.append(geom)

        for detail in location_details['details']:
            # Try using the cnn first, but for some reason the sf streets db
            # doesn't have *every* cnn.
            if detail.has_key('cnn'):
                try:
                    geom = SfStreet.objects.get(cnn=detail['cnn']).location
                except SfStreet.DoesNotExist:
                    pass
                else:
                    geom_set.append(geom)

            # If the cnn wasn't found, and this is an itersection, try getting
            # the location by cross streets.
            else:
                geom = SfStreet.objects.get_intersection(
                    detail['cross_street_1'], detail['cross_street_2'])
                if geom:
                    geom_set.append(geom)

        geom = line_merge(make_geomcoll(geom_set))
        if not geom.empty:
            ni.location = geom
        else:
            self.logger.debug('got an empty geometry from list of geoms: %r' %
                              geom_set)