UPDATE
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def build_default_layout():
|
||||
return {
|
||||
"input_block_count": 1,
|
||||
"default_full_farm": True,
|
||||
"algorithm_status": "pending",
|
||||
"blocks": [
|
||||
{
|
||||
"block_code": "block-1",
|
||||
"order": 1,
|
||||
"source": "default",
|
||||
"needs_subdivision": None,
|
||||
"sub_blocks": [],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("location_data", "0007_ndviobservation"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="soillocation",
|
||||
name="block_layout",
|
||||
field=models.JSONField(
|
||||
blank=True,
|
||||
default=build_default_layout,
|
||||
help_text="ساختار بلوکهای زمین. بهصورت پیشفرض کل زمین یک بلوک است و بعداً الگوریتم میتواند برای هر بلوک زیربلوک تعریف کند.",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="soillocation",
|
||||
name="input_block_count",
|
||||
field=models.PositiveIntegerField(
|
||||
default=1,
|
||||
help_text="تعداد بلوکهای اولیهای که کشاورز برای زمین ثبت میکند.",
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,38 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("location_data", "0008_soillocation_block_layout"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="BlockSubdivision",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("block_code", models.CharField(help_text="شناسه بلوکی که این خردسازی برای آن انجام شده است.", max_length=64)),
|
||||
("source_boundary", models.JSONField(blank=True, default=dict, help_text="مرز همان بلوکی که به سرویس subdivision داده شده است.")),
|
||||
("chunk_size_sqm", models.PositiveIntegerField(default=100, help_text="اندازه هر chunk به متر مربع.")),
|
||||
("grid_points", models.JSONField(blank=True, default=list, help_text="نقاط اولیه شبکه داخل مرز بلوک.")),
|
||||
("centroid_points", models.JSONField(blank=True, default=list, help_text="مراکز نهایی بخشهای خردشده.")),
|
||||
("grid_point_count", models.PositiveIntegerField(default=0)),
|
||||
("centroid_count", models.PositiveIntegerField(default=0)),
|
||||
("status", models.CharField(default="created", help_text="وضعیت تولید subdivision برای این بلوک.", max_length=32)),
|
||||
("metadata", models.JSONField(blank=True, default=dict)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="block_subdivisions", to="location_data.soillocation")),
|
||||
],
|
||||
options={
|
||||
"ordering": ["soil_location", "block_code", "-updated_at"],
|
||||
"verbose_name": "خردسازی بلوک",
|
||||
"verbose_name_plural": "خردسازی بلوکها",
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="blocksubdivision",
|
||||
constraint=models.UniqueConstraint(fields=("soil_location", "block_code"), name="location_block_subdivision_unique_location_block_code"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("location_data", "0009_blocksubdivision"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="blocksubdivision",
|
||||
name="elbow_plot",
|
||||
field=models.ImageField(
|
||||
blank=True,
|
||||
help_text="تصویر نمودار elbow برای انتخاب تعداد بهینه خوشهها.",
|
||||
null=True,
|
||||
upload_to="location_data/elbow_plots/",
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,110 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("location_data", "0010_blocksubdivision_elbow_plot"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="AnalysisGridCell",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("block_code", models.CharField(blank=True, db_index=True, default="", help_text="شناسه بلوکی که این سلول به آن تعلق دارد.", max_length=64)),
|
||||
("cell_code", models.CharField(help_text="شناسه یکتای سلول تحلیل.", max_length=128, unique=True)),
|
||||
("chunk_size_sqm", models.PositiveIntegerField(db_index=True, default=900, help_text="اندازه سلول تحلیل به متر مربع.")),
|
||||
("geometry", models.JSONField(blank=True, default=dict, help_text="هندسه سلول به صورت GeoJSON polygon یا ساختار مشابه.")),
|
||||
("centroid_lat", models.DecimalField(db_index=True, decimal_places=6, help_text="عرض جغرافیایی مرکز سلول.", max_digits=9)),
|
||||
("centroid_lon", models.DecimalField(db_index=True, decimal_places=6, help_text="طول جغرافیایی مرکز سلول.", max_digits=9)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("block_subdivision", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="analysis_grid_cells", to="location_data.blocksubdivision")),
|
||||
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="analysis_grid_cells", to="location_data.soillocation")),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "analysis grid cell",
|
||||
"verbose_name_plural": "analysis grid cells",
|
||||
"ordering": ["soil_location", "block_code", "cell_code"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RemoteSensingRun",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("block_code", models.CharField(blank=True, db_index=True, default="", help_text="شناسه بلوکی که این run برای آن اجرا شده است.", max_length=64)),
|
||||
("provider", models.CharField(default="openeo", help_text="ارائهدهنده داده سنجشازدور.", max_length=64)),
|
||||
("chunk_size_sqm", models.PositiveIntegerField(default=900, help_text="اندازه هر سلول تحلیل به متر مربع.")),
|
||||
("temporal_start", models.DateField(blank=True, null=True)),
|
||||
("temporal_end", models.DateField(blank=True, null=True)),
|
||||
("status", models.CharField(choices=[("pending", "Pending"), ("running", "Running"), ("success", "Success"), ("failure", "Failure")], db_index=True, default="pending", max_length=16)),
|
||||
("metadata", models.JSONField(blank=True, default=dict)),
|
||||
("error_message", models.TextField(blank=True, default="")),
|
||||
("started_at", models.DateTimeField(blank=True, null=True)),
|
||||
("finished_at", models.DateTimeField(blank=True, null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("block_subdivision", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="remote_sensing_runs", to="location_data.blocksubdivision")),
|
||||
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="remote_sensing_runs", to="location_data.soillocation")),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "remote sensing run",
|
||||
"verbose_name_plural": "remote sensing runs",
|
||||
"ordering": ["-created_at", "-id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="AnalysisGridObservation",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("temporal_start", models.DateField(db_index=True)),
|
||||
("temporal_end", models.DateField(db_index=True)),
|
||||
("ndvi", models.FloatField(blank=True, null=True)),
|
||||
("ndwi", models.FloatField(blank=True, null=True)),
|
||||
("lst_c", models.FloatField(blank=True, null=True)),
|
||||
("soil_vv", models.FloatField(blank=True, null=True)),
|
||||
("soil_vv_db", models.FloatField(blank=True, null=True)),
|
||||
("dem_m", models.FloatField(blank=True, null=True)),
|
||||
("slope_deg", models.FloatField(blank=True, null=True)),
|
||||
("metadata", models.JSONField(blank=True, default=dict)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("cell", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="observations", to="location_data.analysisgridcell")),
|
||||
("run", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="observations", to="location_data.remotesensingrun")),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "analysis grid observation",
|
||||
"verbose_name_plural": "analysis grid observations",
|
||||
"ordering": ["-temporal_start", "-temporal_end", "-id"],
|
||||
},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="analysisgridcell",
|
||||
index=models.Index(fields=["soil_location", "block_code"], name="grid_cell_loc_block_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="analysisgridcell",
|
||||
index=models.Index(fields=["soil_location", "chunk_size_sqm"], name="grid_cell_loc_chunk_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="remotesensingrun",
|
||||
index=models.Index(fields=["soil_location", "status", "created_at"], name="rs_run_loc_status_created_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="remotesensingrun",
|
||||
index=models.Index(fields=["block_code", "created_at"], name="rs_run_block_created_idx"),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="analysisgridobservation",
|
||||
constraint=models.UniqueConstraint(fields=("cell", "temporal_start", "temporal_end"), name="grid_obs_unique_cell_temporal_range"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="analysisgridobservation",
|
||||
index=models.Index(fields=["cell", "temporal_start", "temporal_end"], name="grid_obs_cell_temporal_idx"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="analysisgridobservation",
|
||||
index=models.Index(fields=["temporal_start", "temporal_end"], name="grid_obs_temporal_idx"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,65 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("location_data", "0011_remote_sensing_models"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="RemoteSensingSubdivisionResult",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("block_code", models.CharField(blank=True, db_index=True, default="", max_length=64)),
|
||||
("chunk_size_sqm", models.PositiveIntegerField(default=900)),
|
||||
("temporal_start", models.DateField(db_index=True)),
|
||||
("temporal_end", models.DateField(db_index=True)),
|
||||
("cluster_count", models.PositiveIntegerField(default=0)),
|
||||
("selected_features", models.JSONField(blank=True, default=list)),
|
||||
("skipped_cell_codes", models.JSONField(blank=True, default=list)),
|
||||
("metadata", models.JSONField(blank=True, default=dict)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("block_subdivision", models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL, related_name="remote_sensing_subdivision_results", to="location_data.blocksubdivision")),
|
||||
("run", models.OneToOneField(on_delete=models.deletion.CASCADE, related_name="subdivision_result", to="location_data.remotesensingrun")),
|
||||
("soil_location", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="remote_sensing_subdivision_results", to="location_data.soillocation")),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "remote sensing subdivision result",
|
||||
"verbose_name_plural": "remote sensing subdivision results",
|
||||
"ordering": ["-created_at", "-id"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="RemoteSensingClusterAssignment",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("cluster_label", models.PositiveIntegerField(db_index=True)),
|
||||
("raw_feature_values", models.JSONField(blank=True, default=dict)),
|
||||
("scaled_feature_values", models.JSONField(blank=True, default=dict)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
("cell", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="cluster_assignments", to="location_data.analysisgridcell")),
|
||||
("result", models.ForeignKey(on_delete=models.deletion.CASCADE, related_name="assignments", to="location_data.remotesensingsubdivisionresult")),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "remote sensing cluster assignment",
|
||||
"verbose_name_plural": "remote sensing cluster assignments",
|
||||
"ordering": ["cluster_label", "cell__cell_code"],
|
||||
},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="remotesensingsubdivisionresult",
|
||||
index=models.Index(fields=["soil_location", "block_code", "temporal_start", "temporal_end"], name="rs_subdiv_result_lookup_idx"),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="remotesensingclusterassignment",
|
||||
constraint=models.UniqueConstraint(fields=("result", "cell"), name="rs_cluster_assign_unique_result_cell"),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="remotesensingclusterassignment",
|
||||
index=models.Index(fields=["result", "cluster_label"], name="rs_cluster_assign_result_label_idx"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("location_data", "0012_remote_sensing_subdivision_models"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name="SoilDepthData",
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("location_data", "0013_remove_soildepthdata"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="blocksubdivision",
|
||||
name="chunk_size_sqm",
|
||||
field=models.PositiveIntegerField(default=900, help_text="اندازه هر chunk به متر مربع."),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user