This commit is contained in:
2022-03-02 19:24:56 +05:30
parent 0d3b3279de
commit 48176ab935
5 changed files with 259 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import os, zipfile, glob
import environ
from geo.Postgres import Db
from sqlalchemy.sql.functions import mode
from .mapping import location_mapping
from .mapping import location_mapping, location_line_mapping, location_polygon_mapping
from .choices import LAYER_CHOICES
from django.contrib.gis.utils import LayerMapping
@ -84,6 +84,100 @@ class Location(models.Model):
return self.location_name
class Location(models.Model):
location_id=models.IntegerField(_('Location id'), blank=True, null=True)
location_name=models.CharField(_('Location Name'), max_length=255)
category=models.CharField(_('Category'), max_length=255, blank=True, null=True)
zip=models.CharField(_('Zip code'), max_length=12, blank=True, null=True)
address = models.CharField(_('Address'), max_length=512, blank=True, null=True)
prefecture = models.CharField(_('Prefecture'), max_length=255, blank=True, null=True)
area= models.CharField(_('Area'), max_length=255, blank=True, null=True)
city= models.CharField(_('City'), max_length=255, blank=True, null=True)
photos=models.CharField(_('Phptos'), max_length=255, blank=True, null=True)
videos=models.CharField(_('Videos'), max_length=255, blank=True, null=True)
webcontents=models.CharField(_('Web Content'), max_length=255, blank=True, null=True)
status=models.CharField(_('Status'),max_length=255, blank=True, null=True)
portal=models.CharField(_('Status'), max_length=255,blank=True, null=True)
group=models.CharField(_('Status'), max_length=255,blank=True, null=True)
phone=models.CharField(_('Status'), max_length=255,blank=True, null=True)
fax=models.CharField(_('Status'), max_length=255, blank=True, null=True)
email=models.EmailField(_('Email'), max_length=255,blank=True, null=True)
facility=models.CharField(_('Status'), max_length=255, blank=True, null=True)
remark=models.CharField(_('Status'), max_length=255, blank=True, null=True)
tags=models.CharField(_('Tags'), max_length=512, blank=True, null=True)
parammeters=models.CharField(_('Parameters'), max_length=512, blank=True, null=True)
created_at=models.DateTimeField(auto_now_add=True)
last_updated_user=models.ForeignKey(User, related_name="location_updated_user", on_delete=models.DO_NOTHING,blank=True, null=True)
last_updated_at=models.DateTimeField(auto_now=True)
geom=models.MultiPointField(srid=4326)
def __str__(self):
return self.location_name
class Location_line(models.Model):
location_id=models.IntegerField(_('Location id'), blank=True, null=True)
location_name=models.CharField(_('Location Name'), max_length=255)
category=models.CharField(_('Category'), max_length=255, blank=True, null=True)
zip=models.CharField(_('Zip code'), max_length=12, blank=True, null=True)
address = models.CharField(_('Address'), max_length=512, blank=True, null=True)
prefecture = models.CharField(_('Prefecture'), max_length=255, blank=True, null=True)
area= models.CharField(_('Area'), max_length=255, blank=True, null=True)
city= models.CharField(_('City'), max_length=255, blank=True, null=True)
photos=models.CharField(_('Phptos'), max_length=255, blank=True, null=True)
videos=models.CharField(_('Videos'), max_length=255, blank=True, null=True)
webcontents=models.CharField(_('Web Content'), max_length=255, blank=True, null=True)
status=models.CharField(_('Status'),max_length=255, blank=True, null=True)
portal=models.CharField(_('Status'), max_length=255,blank=True, null=True)
group=models.CharField(_('Status'), max_length=255,blank=True, null=True)
phone=models.CharField(_('Status'), max_length=255,blank=True, null=True)
fax=models.CharField(_('Status'), max_length=255, blank=True, null=True)
email=models.EmailField(_('Email'), max_length=255,blank=True, null=True)
facility=models.CharField(_('Status'), max_length=255, blank=True, null=True)
remark=models.CharField(_('Status'), max_length=255, blank=True, null=True)
tags=models.CharField(_('Tags'), max_length=512, blank=True, null=True)
parammeters=models.CharField(_('Parameters'), max_length=512, blank=True, null=True)
created_at=models.DateTimeField(auto_now_add=True)
last_updated_user=models.ForeignKey(User, related_name="location_line_updated_user", on_delete=models.DO_NOTHING,blank=True, null=True)
last_updated_at=models.DateTimeField(auto_now=True)
geom=models.MultiLineStringField(srid=4326)
def __str__(self):
return self.location_name
class Location_polygon(models.Model):
location_id=models.IntegerField(_('Location id'), blank=True, null=True)
location_name=models.CharField(_('Location Name'), max_length=255)
category=models.CharField(_('Category'), max_length=255, blank=True, null=True)
zip=models.CharField(_('Zip code'), max_length=12, blank=True, null=True)
address = models.CharField(_('Address'), max_length=512, blank=True, null=True)
prefecture = models.CharField(_('Prefecture'), max_length=255, blank=True, null=True)
area= models.CharField(_('Area'), max_length=255, blank=True, null=True)
city= models.CharField(_('City'), max_length=255, blank=True, null=True)
photos=models.CharField(_('Phptos'), max_length=255, blank=True, null=True)
videos=models.CharField(_('Videos'), max_length=255, blank=True, null=True)
webcontents=models.CharField(_('Web Content'), max_length=255, blank=True, null=True)
status=models.CharField(_('Status'),max_length=255, blank=True, null=True)
portal=models.CharField(_('Status'), max_length=255,blank=True, null=True)
group=models.CharField(_('Status'), max_length=255,blank=True, null=True)
phone=models.CharField(_('Status'), max_length=255,blank=True, null=True)
fax=models.CharField(_('Status'), max_length=255, blank=True, null=True)
email=models.EmailField(_('Email'), max_length=255,blank=True, null=True)
facility=models.CharField(_('Status'), max_length=255, blank=True, null=True)
remark=models.CharField(_('Status'), max_length=255, blank=True, null=True)
tags=models.CharField(_('Tags'), max_length=512, blank=True, null=True)
parammeters=models.CharField(_('Parameters'), max_length=512, blank=True, null=True)
created_at=models.DateTimeField(auto_now_add=True)
last_updated_user=models.ForeignKey(User, related_name="location_polygon_updated_user", on_delete=models.DO_NOTHING,blank=True, null=True)
last_updated_at=models.DateTimeField(auto_now=True)
geom=models.MultiPolygonField(srid=4326)
def __str__(self):
return self.location_name
EVENT_STATUS = (
("PREPARING", _("Preparing")),
("PROMOTION", _("Promotion")),
@ -224,10 +318,18 @@ class ShopRoute(models.Model):
def getTableForModel(tbl):
if tbl == 1:
return Location.objects.model._meta.db_table;
elif tbl == 2:
return Location_line.objects.model._meta.db_table;
else:
return Location_polygon.objects.model._meta.db_table;
def getMappingforModel(tbl, shp):
if tbl == 1:
return LayerMapping(Location, shp, location_mapping, transform=False)
elif tbl == 2:
return LayerMapping(Location_line, location_line_mapping, transform=False)
else:
return LayerMapping(Location_polygon, location_polygon_mapping, transform=False)
class ShapeLayers(models.Model):