Exemplo n.º 1
0
async def test_multipoint_should_round(connection, expected):
    geom = MultiPoint(expected, srid=4326)
    await connection.execute('INSERT INTO multipoint_async (geom) VALUES ($1)',
                             geom)
    geom = await connection.fetchval(
        'SELECT geom FROM multipoint_async WHERE '
        'geom=$1', geom, column=0)
    assert geom.coords == expected
Exemplo n.º 2
0
 def getValues(self):
     """
     Geometry representing the values taken by the temporal value.
     """
     values = [seq.getValues for seq in self._sequenceList]
     points = [geo for geo in values if isinstance(geo, Point)]
     lines = [geo for geo in values if isinstance(geo, LineString)]
     if len(points) != 0 and len(points) != 0:
         return GeometryCollection(points + lines)
     if len(points) != 0 and len(points) == 0:
         return MultiPoint(points)
     if len(points) == 0 and len(points) != 0:
         return MultiLineString(lines)
Exemplo n.º 3
0
def test_tgeompointi_accessors(cursor, expected_tgeompointinstset):
    assert TGeomPointInstSet(expected_tgeompointinstset).srid == 4326
    assert TGeomPointInstSet(expected_tgeompointinstset).tempSubtype() == 'InstantSet'
    assert TGeomPointInstSet(expected_tgeompointinstset).getValues == \
           MultiPoint([Point(10.0, 10.0),Point(20.0, 20.0),Point(30.0, 30.0)])
    assert TGeomPointInstSet(expected_tgeompointinstset).startValue == Point(10.0, 10.0)
    assert TGeomPointInstSet(expected_tgeompointinstset).endValue == Point(30.0, 30.0)
    assert TGeomPointInstSet(expected_tgeompointinstset).getTime == \
           PeriodSet(
               '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01], [2019-09-02 00:00:00+01, 2019-09-02 00:00:00+01], '
               '[2019-09-03 00:00:00+01, 2019-09-03 00:00:00+01]}')
    assert TGeomPointInstSet(expected_tgeompointinstset).duration == timedelta(0)
    assert TGeomPointInstSet(expected_tgeompointinstset).timespan == timedelta(2)
    assert TGeomPointInstSet(expected_tgeompointinstset).period == Period('[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]')
    assert TGeomPointInstSet(expected_tgeompointinstset).numInstants == 3
    assert TGeomPointInstSet(expected_tgeompointinstset).startInstant == TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01')
    assert TGeomPointInstSet(expected_tgeompointinstset).endInstant == TGeomPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01')
    assert TGeomPointInstSet(expected_tgeompointinstset).instantN(2) == TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01')
    assert TGeomPointInstSet(expected_tgeompointinstset).instants == [TGeomPointInst('Point(10.0 10.0)@2019-09-01 00:00:00+01'),
                                                            TGeomPointInst('Point(20.0 20.0)@2019-09-02 00:00:00+01'),
                                                            TGeomPointInst('Point(30.0 30.0)@2019-09-03 00:00:00+01')]
    assert TGeomPointInstSet(expected_tgeompointinstset).numTimestamps == 3
    assert TGeomPointInstSet(expected_tgeompointinstset).startTimestamp == parse('2019-09-01 00:00:00+01')
    assert TGeomPointInstSet(expected_tgeompointinstset).endTimestamp == parse('2019-09-03 00:00:00+01')
    assert TGeomPointInstSet(expected_tgeompointinstset).timestampN(2) == parse('2019-09-02 00:00:00+01')
    assert TGeomPointInstSet(expected_tgeompointinstset).timestamps == [parse('2019-09-01 00:00:00+01'),
                                                              parse('2019-09-02 00:00:00+01'),
                                                              parse('2019-09-03 00:00:00+01')]
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsTimestamp(parse('2019-09-04 00:00:00+01')) == False
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsTimestampSet(
        TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsTimestampSet(
        TimestampSet('{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsPeriod(
        Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsPeriod(
        Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)')) == False
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsPeriod(
        Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsPeriodSet(
        PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsPeriodSet(
        PeriodSet('{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01)}')) == False
    assert TGeomPointInstSet(expected_tgeompointinstset).intersectsPeriodSet(
        PeriodSet('{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
Exemplo n.º 4
0
def test_multipoint_should_round(cursor, expected):
    params = [MultiPoint(expected, srid=4326)]
    cursor.execute('INSERT INTO multipoint (geom) VALUES (%s)', params)
    cursor.execute('SELECT geom FROM multipoint WHERE geom=%s', params)
    geom = cursor.fetchone()[0]
    assert geom.coords == expected
Exemplo n.º 5
0
 def getValues(self):
     """
     Geometry representing the values taken by the temporal value.
     """
     values = super().getValues
     return MultiPoint(values)
def test_multipoint_geojson():
    line = MultiPoint(((1, 2), (3, 4)))
    assert line.geojson == {
        "type": "MultiPoint",
        "coordinates": ((1, 2), (3, 4))
    }
def test_multipoint_get_item():
    multi = MultiPoint(((30, 10), (10, 30), (40, 40)))
    assert multi[0] == Point(30, 10)
def test_geom_should_compare_with_coords():
    assert ((30, 10), (10, 30), (40, 40)) == MultiPoint(
        ((30, 10), (10, 30), (40, 40)))  # noqa