Hi David,

thanks for your help. I tried setting dim to 4 but did't see any change.

Here is my model:

```python
from django.contrib.gis.db import models


class Kmsys(models.Model):
# Define constants ----------------------------
EPSG_CODE = 31287
NAME_OF_GEOMETRY_FIELD = "geom"

# F I E L D S -------------------------------------------------
id = models.IntegerField(primary_key=True)

geom = models.MultiLineStringField(
dim=4, srid=EPSG_CODE, blank=True, null=True, spatial_index=True
) # EPSG:31287=AustriaLambert

object_id = models.BigIntegerField(db_column="OBJECTID", unique=True)
code = models.CharField(max_length=80, db_column="KMSYS_CODE", unique=False)
name = models.CharField(max_length=500, db_column="KMSYS_BEZEICHNUNG", 
unique=False)
start_date = models.DateTimeField(db_column="KMSYS_START_DATUM")
end_date = models.DateTimeField(db_column="KMSYS_ENDE_DATUM")
len = models.FloatField(db_column="LEN")
km_from = models.FloatField(db_column="KMSYS_KMVON")
km_till = models.FloatField(db_column="KMSYS_KMBIS")
parts_quantity = models.IntegerField(db_column="TEILE_ANZ")
fme_date = models.DateTimeField(db_column="FME_DATUM")
se_anno_cad_data = models.FileField(db_column="SE_ANNO_CAD_DATA")
bauk_id = models.FloatField(db_column="BAUK_ID")

# Meta-Class ------------------------------------------------------
class Meta:
managed = False
db_table = "KMSYS"
# db_table = '"public"."KMSYS"'

verbose_name = "Kmsys"
verbose_name_plural = "Kmsys"
ordering = ["code"]

# Methods ---------------------------------------------------------
def __str__(self) -> str:
"""String for representing the Model object."""
return f"{self.code} | {self.name} | {self.start_date} | {self.end_date} | {
self.km_from} | {self.km_till} | {self.parts_quantity} | {self.fme_date} | {
self.se_anno_cad_data} | {self.bauk_id}"
```

And this is the pytest that keeps failing -> At the beginning i just tested 
the dim=3 manually without db-access

from django.contrib.gis.geos import GEOSGeometry, LineString, 
MultiLineString, Point
from rest_framework.reverse import reverse

import logging

import pytest

from kmsys.models import Kmsys
from kmsys.test.test_runner import DjangoNoCreateAndDropRunner

logger = logging.getLogger(__name__)

# use pytest marks to tell pytest-django your test needs database access! 
In case only a certain method needs db-access use @pytest.mark.django_db as 
decorator of the according test-method.
pytestmark = pytest.mark.django_db


class TestModel:
"""
Test suite for KMSYS
"""

def test_query_kmsys(self):
"""
Test whether the kmsys can be accessed.

"""
# ARRANGE -------------

# simple dimension test with GDAL
# p: OGRGeometry = OGRGeometry("Point (1 2 3 )")
# assert p.coord_dim == 3

# simple dimension test with GEOS
p: GEOSGeometry = GEOSGeometry("Point (1 2 3 )")
assert p.hasz

# simple dimension test with GEOS Multilinestring
ls1 = LineString([(0, 0, 150), (1, 1, 151)], srid="31287")
ls2 = LineString([(2, 2, 153), (3, 3, 154)], srid="31287")
mls = MultiLineString(ls1, ls2)
assert mls.hasz

# ACT -----------------
first_kmsys: Kmsys = Kmsys.objects.all().first()
logger.info(f"first: {first_kmsys}")

# ASSERT -----------------
assert first_kmsys.geom.hasz
assert len(first_kmsys.geom.coords[0][0]) == 3
assert len(Kmsys.objects.all()) == 388

regards Richard
David James Nwoyie schrieb am Samstag, 24. Februar 2024 um 21:01:56 UTC+1:

> Increase the dim to 4 because of the Django of use 0 as the starting point 
>
> On Sat, Feb 24, 2024, 8:48 PM Richard Mair <[email protected]> wrote:
>
>> Hi i am using
>>
>> geom = models.MultiLineStringField(
>> dim=3, srid=EPSG_CODE, blank=True, null=True, spatial_index=True
>> ) # EPSG:3128=AustriaLambert
>>
>>
>> and my PostGIS-DB is using (MultilinestringM
>>
>> ALTER TABLE IF EXISTS public."KMSYS"
>>     ADD COLUMN geom geometry(MultiLineStringM,31287);
>>
>> but when I access my Model I only get 2 dimensional response
>>
>> Can anybody lead me to the correct handling
>>
>>
>>
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ae4eaa11-3f4b-467a-9931-bbff5892a858n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/ae4eaa11-3f4b-467a-9931-bbff5892a858n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/85f472cb-8cee-4e32-b4c3-edec9b0324c1n%40googlegroups.com.

Reply via email to