polygon = Polygon(coords).simplify(0.00015)
coords = list(polygon.exterior.coords)
lng_list = list()
last_lng = None
lat_list = list()
last_lat = None
for val in coords:
if not last_lng:
lng_list.append(val[0])
lat_list.append(val[1])
else:
lng_list.append(round(val[0] - last_lng, 6))
lat_list.append(round(val[1] - last_lat, 6))
last_lng = val[0]
last_lat = val[1]
return {
'lat': lat_list,
'lng': lng_list
}
b64encode(zlib.compress(json.dumps(data).encode('utf-8')))
let newData = atob(data)
newData = newData.split('').map(function (e) {
return e.charCodeAt(0)
})
newData = new Uint8Array(newData)
newData = pako.inflate(newData)
newData = new TextDecoder().decode(newData)
return JSON.parse(newData)
let lastLat = null
let lastLng = null
let result = []
coords.forEach(val => {
let newCoords = []
for (const [index, el] of val.lat.entries()) {
if (!index) {
lastLat = val.lat[0]
lastLng = val.lng[0]
} else {
lastLng += val.lng[index]
lastLat += val.lat[index]
}
newCoords.push([lastLng, lastLat])
}
result.push(newCoords)
})
parent_categories= models.ManyToManyField('ParentCategory', related_name='modules', through='ModuleParentCategory')
class ModuleParentCategory(models.Model):
module = models.ForeignKey(Module, on_delete=models.CASCADE)
parent_category = models.ForeignKey(ParentCategory, on_delete=models.CASCADE)
primary = models.BooleanField(default=False)
<label for="fname">Your toggle:</label><br>
<input v-model.number="input" type="text" id="fname" style="border: 1px solid black">
<button @click="toggle(input)">Change toggle view</button>
<div class="nav-drop" v-for="(el, index) in listToShow" :key="index">
{{el}}
</div>
export default {
name: "Test",
data: () => ({
toggles: [
1,
2,
3,
4,
5
],
hiddenToggles: [],
input: '',
}),
methods: {
toggle(value) {
if (!value)
return
let index = this.hiddenToggles.findIndex(el => value === el)
if (index > -1)
this.hiddenToggles.splice(index, 1)
else
this.hiddenToggles.push(value)
},
},
computed: {
listToShow() {
return this.toggles.filter(value =>
this.hiddenToggles.findIndex(el => el === value) === -1)
}
}
}
outputDir: '../static/dist',
publicPath: process.env.NODE_ENV === 'production'
? '/static/dist/'
: '/',
indexPath: process.env.NODE_ENV === 'production'
? '../../templates/index.html'
: 'index.html',