Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions jmeos-core/src/main/java/types/basic/tfloat/TFloat.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,9 @@ default float end_value(){
tint_values
*/
default FloatSet value_set(){
// Create a JNR-FFI runtime instance
Runtime runtime = Runtime.getSystemRuntime();
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer = GeneratedFunctions.tfloat_values(this.getNumberInner(), intPointer);
StringBuilder sb = null;
sb.append("{");
int count= intPointer.getInt(0);
for (int i=0;i<count;i++){
double res= resPointer.getDouble((long) i *Double.BYTES);
sb.append(res);
if(i<count-1){
sb.append(", ");
}
}
sb.append("}");
System.out.println(sb.toString());
return new FloatSet(sb.toString());
Pointer countPointer = Memory.allocate(Runtime.getSystemRuntime(), Integer.BYTES);
Pointer values = GeneratedFunctions.tfloat_values(this.getNumberInner(), countPointer);
return new FloatSet(GeneratedFunctions.floatset_make(values, countPointer.getInt(0)));
}

/**
Expand Down
23 changes: 4 additions & 19 deletions jmeos-core/src/main/java/types/basic/tpoint/tgeog/TGeogPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,10 @@ static TGeogPoint from_base_time(Geometry value, Time base, TInterpolation inter
}

default GeographySet value_set(int precision) throws ParseException {
// Create a JNR-FFI runtime instance
Runtime runtime = Runtime.getSystemRuntime();
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.tgeo_values(this.getPointInner(), intPointer);
List<TPoint> pointList= new ArrayList<>();
int count= intPointer.getInt(0);
StringBuilder sb = null;
sb.append("{");
for(int i=0;i<count;i++) {
Point p= ConversionUtils.gserialized_to_shapely_point(resPointer.getPointer((long) i *Long.BYTES), precision);
sb.append(p);
if(i<count-1){
sb.append(", ");
}
}
sb.append("}");
System.out.println(sb.toString());
return new GeographySet(sb.toString());
Pointer countPointer = Memory.allocate(Runtime.getSystemRuntime(), Integer.BYTES);
Pointer values = GeneratedFunctions.tgeo_values(this.getPointInner(), countPointer);
return new GeographySet(GeneratedFunctions.set_round(
GeneratedFunctions.geoset_make(values, countPointer.getInt(0)), precision));
}

/* ------------------------- Conversions ---------------------------------- */
Expand Down
23 changes: 4 additions & 19 deletions jmeos-core/src/main/java/types/basic/tpoint/tgeom/TGeomPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,25 +238,10 @@ default TBool temporal_not_equal(Point other){
}

default GeometrySet value_set(int precision) throws ParseException {
// Create a JNR-FFI runtime instance
Runtime runtime = Runtime.getSystemRuntime();
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.tgeo_values(this.getPointInner(), intPointer);
List<TPoint> pointList= new ArrayList<>();
int count= intPointer.getInt(0);
StringBuilder sb = null;
sb.append("{");
for(int i=0;i<count;i++) {
Point p= ConversionUtils.gserialized_to_shapely_point(resPointer.getPointer((long) i *Long.BYTES), precision);
sb.append(p);
if(i<count-1){
sb.append(", ");
}
}
sb.append("}");
System.out.println(sb.toString());
return new GeometrySet(sb.toString());
Pointer countPointer = Memory.allocate(Runtime.getSystemRuntime(), Integer.BYTES);
Pointer values = GeneratedFunctions.tgeo_values(this.getPointInner(), countPointer);
return new GeometrySet(GeneratedFunctions.set_round(
GeneratedFunctions.geoset_make(values, countPointer.getInt(0)), precision));
}


Expand Down
47 changes: 4 additions & 43 deletions jmeos-core/src/main/java/types/basic/ttext/TText.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import types.basic.tfloat.TFloatSeqSet;
import types.basic.tpoint.TPoint;
import types.collections.base.Set;
import types.collections.text.TextSet;
import types.collections.time.tstzset;
import types.collections.time.tstzspan;
import types.collections.time.Time;
Expand Down Expand Up @@ -144,49 +145,9 @@ default String as_wkt(){
*/

default Set<String> value_set(){
// Create a JNR-FFI runtime instance
Runtime runtime = Runtime.getSystemRuntime();
// Allocate memory for an integer (4 bytes) but do not set a value
Pointer intPointer = Memory.allocate(runtime, 4);
Pointer resPointer= GeneratedFunctions.ttext_values(this.getTextInner(), intPointer);
StringBuilder sb= null;
sb.append("{");
int count= intPointer.getInt(0);
for(int i=0; i<count; i++){
Pointer res= resPointer.getPointer((long) i *Long.BYTES);
String resString= GeneratedFunctions.text_to_cstring(res);
sb.append(resString);
if(i<count-1){
sb.append(", ");
}
}
sb.append("}");
return new Set<String>() {
@Override
public Pointer get_inner() {
return resPointer;
}

@Override
public Pointer createInner(Pointer inner) {
return inner;
}

@Override
public Pointer createStringInner(String str) {
return GeneratedFunctions.ttext_in(str);
}

@Override
public String start_element() throws ParseException {
return GeneratedFunctions.text_to_cstring(GeneratedFunctions.ttext_min_value(getTextInner()));
}

@Override
public String end_element() throws ParseException {
return GeneratedFunctions.text_to_cstring(GeneratedFunctions.ttext_max_value(getTextInner()));
}
};
Pointer countPointer = Memory.allocate(Runtime.getSystemRuntime(), Integer.BYTES);
Pointer values = GeneratedFunctions.ttext_values(this.getTextInner(), countPointer);
return new TextSet(GeneratedFunctions.textset_make(values, countPointer.getInt(0)));
}

/**
Expand Down
8 changes: 7 additions & 1 deletion jmeos-core/src/test/java/basic/TFloatTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -889,4 +889,10 @@ void testEverGreater(Temporal source, String type, float arg, boolean expected)
}


}
@org.junit.jupiter.api.Test
void testValueSet() {
GeneratedFunctions.meos_initialize_timezone("UTC");
assertEquals("{1.5, 2.5}", GeneratedFunctions.set_out(new TFloatSeq(
"[1.5@2019-09-01, 2.5@2019-09-02, 1.5@2019-09-03]").value_set().get_inner(), 15));
}
}
11 changes: 10 additions & 1 deletion jmeos-core/src/test/java/basic/TGeogPointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1086,4 +1086,13 @@ void testAppendSequence(Temporal source, String type, TGeogPointSeq tgeoseq, Tem


}
}


@org.junit.jupiter.api.Test
void testValueSet() throws ParseException {
GeneratedFunctions.meos_initialize_timezone("UTC");
TGeogPointSeq source = new TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]");
assertEquals("SRID=4326;{\"POINT(1 1)\", \"POINT(2 2)\"}",
GeneratedFunctions.spatialset_as_ewkt(source.value_set(6).get_inner(), 6));
}
}
10 changes: 10 additions & 0 deletions jmeos-core/src/test/java/basic/TGeomPointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1146,4 +1146,14 @@ void testValuesStboxesMakeSimple() {
assertEquals("[POINT(2 0)@2019-09-03 00:00:00+00, POINT(0 2)@2019-09-04 00:00:00+00]",
simple.get(1).to_string());
}


@org.junit.jupiter.api.Test
void testValueSet() throws ParseException {
GeneratedFunctions.meos_initialize_timezone("UTC");
TGeomPointSeq source = new TGeomPointSeq(
"SRID=3812;[Point(1.123456 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1.123456 1)@2019-09-03]");
assertEquals("SRID=3812;{\"POINT(1.12 1)\", \"POINT(2 2)\"}",
GeneratedFunctions.spatialset_as_ewkt(source.value_set(2).get_inner(), 6));
}
}
8 changes: 8 additions & 0 deletions jmeos-core/src/test/java/basic/TTextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,12 @@ public void testAppendSeq(Temporal base, TSequence base2, Temporal tseq, String
assertEquals(((TTextSeqSet)base.append_sequence(base2)).to_string(), ((TTextSeqSet) tseq).to_string());
}
}


@org.junit.jupiter.api.Test
void testValueSet() {
GeneratedFunctions.meos_initialize_timezone("UTC");
assertEquals("{\"AAA\", \"BBB\"}",
new TTextSeq("[BBB@2019-09-01, AAA@2019-09-02, BBB@2019-09-03]").value_set().toString());
}
}
Loading