Add abbreviations.
This commit is contained in:
parent
c5501c7ff6
commit
3a09d2d314
|
@ -24,7 +24,7 @@ class FeatureSearchManager(models.GeoManager):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute("""SELECT set_limit(%f)""" % threshold)
|
cursor.execute("""SELECT set_limit(%f)""" % threshold)
|
||||||
|
|
||||||
def find(self, bbox=None, text=None, adm1=None, adm2=None srid=4326):
|
def find(self, bbox=None, text=None, adm1=None, adm2=None, threshold=0.35, srid=4326):
|
||||||
qset = self.get_query_set()
|
qset = self.get_query_set()
|
||||||
if bbox:
|
if bbox:
|
||||||
(minx, miny, maxx, maxy) = bbox
|
(minx, miny, maxx, maxy) = bbox
|
||||||
|
@ -32,6 +32,7 @@ class FeatureSearchManager(models.GeoManager):
|
||||||
if srid != 4326: bbox.transform(4326) # convert to lon/lat
|
if srid != 4326: bbox.transform(4326) # convert to lon/lat
|
||||||
qset = qset.filter(geometry__bboverlaps=bbox)
|
qset = qset.filter(geometry__bboverlaps=bbox)
|
||||||
if text:
|
if text:
|
||||||
|
self.set_threshold(threshold)
|
||||||
text = text.replace("'", "''") # escape the '
|
text = text.replace("'", "''") # escape the '
|
||||||
# use the pg_trgm index
|
# use the pg_trgm index
|
||||||
qset = qset.extra(select={"similarity":"similarity(preferred_name, '%s')"},
|
qset = qset.extra(select={"similarity":"similarity(preferred_name, '%s')"},
|
||||||
|
@ -144,9 +145,10 @@ LANGUAGE_CHOICES = (
|
||||||
|
|
||||||
NAME_TYPE_CHOICES = (
|
NAME_TYPE_CHOICES = (
|
||||||
('alternate', 'alternate'),
|
('alternate', 'alternate'),
|
||||||
('official', 'official'),
|
('abbreviation', 'abbreviation'),
|
||||||
('historic', 'historic'),
|
|
||||||
('colloquial', 'colloquial'),
|
('colloquial', 'colloquial'),
|
||||||
|
('historic', 'historic'),
|
||||||
|
('official', 'official'),
|
||||||
('icao', 'ICAO code'),
|
('icao', 'ICAO code'),
|
||||||
('iata', 'IATA code'),
|
('iata', 'IATA code'),
|
||||||
('postcode', 'ZIP code'),
|
('postcode', 'ZIP code'),
|
||||||
|
@ -205,12 +207,12 @@ RELATIONSHIP_CHOICES = (
|
||||||
)
|
)
|
||||||
|
|
||||||
class Relationship(models.Model):
|
class Relationship(models.Model):
|
||||||
feature1 = models.ForeignKey(Feature, related_name="feauture_from")
|
feature1 = models.ForeignKey(Feature, related_name="feature_from")
|
||||||
feature2 = models.ForeignKey(Feature, related_name="feature_to")
|
feature2 = models.ForeignKey(Feature, related_name="feature_to")
|
||||||
relationship_type = models.CharField(max_length=64, choices=RELATIONSHIP_CHOICES)
|
relationship_type = models.CharField(max_length=64, choices=RELATIONSHIP_CHOICES)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "%s: %s to %s" % (self.relationship_type, self.feature1.preferred_name, self.feature2.preferred_name,)
|
return "%s %s %s" % (self.feature1.preferred_name, self.relationship_type, self.feature2.preferred_name,)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Relation"
|
verbose_name = "Relation"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user