You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
4.1 KiB
Java

package eu.dnetlib.ariadneplus.elasticsearch;
import org.elasticsearch.common.geo.GeoPoint;
import org.junit.Before;
import org.junit.Test;
public class BulkUploadTest {
private BulkUpload bu;
@Before
public void setup(){
bu = new BulkUpload();
}
@Test
public void testCalculateCentroidPoint(){
String wkt = "POINT (30 10)";
GeoPoint centroid = bu.calculateCentroid(wkt);
System.out.println("Long: "+centroid.getLon()+", Lat: "+centroid.getLat());
}
@Test
public void testCalculateCentroidMultiPolygon(){
String wkt = "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))";
GeoPoint centroid = bu.calculateCentroid(wkt);
System.out.println("Long: "+centroid.getLon()+", Lat: "+centroid.getLat());
}
@Test
public void testCalculateCentroidPolygon(){
String wkt = "POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))";
GeoPoint centroid = bu.calculateCentroid(wkt);
System.out.println("Long: "+centroid.getLon()+", Lat: "+centroid.getLat());
}
@Test
public void testCalculateCentroidBB(){
String wkt = "polygon ((-1.42173131195844 51.778172135497, -1.42173131195844 51.7692537152273, -1.40712262768071 51.7692537152273, -1.40712262768071 51.778172135497, -1.42173131195844 51.778172135497))";
GeoPoint centroid = bu.calculateCentroid(wkt);
System.out.println("Long: "+centroid.getLon()+", Lat: "+centroid.getLat());
}
@Test
public void testErrorWkt(){
String wkt = "POLYGON ((14.992851606, 49.997701819, 14.99285127, 49.997700687, 14.992851522, 49.997699286, 14.992852444, 49.99769864, 14.992854204, 49.997697993, 14.992855629, 49.997698101, 14.992857473, 49.997698694, 14.992859066, 49.997699771, 14.99286049, 49.997701172, 14.992862251, 49.997702358, 14.992864346, 49.997704028, 14.992865687, 49.997705644, 14.992867867, 49.997706937, 14.992869962, 49.997708877, 14.992871387, 49.997710116, 14.992871555, 49.997711194, 14.992870633, 49.997712433, 14.992869124, 49.997713457, 14.992867531, 49.997714103, 14.99286619, 49.997714157, 14.992864765, 49.997714157, 14.99286334, 49.997713888, 14.992861832, 49.997712756, 14.992860239, 49.997711248, 14.992858395, 49.997709847, 14.992856719, 49.997708446, 14.992855629, 49.997706991, 14.992854288, 49.997705429, 14.992852863, 49.997704082, 14.992851606, 49.997702789, 14.992851606, 49.997701819))";
GeoPoint centroid = bu.calculateCentroid(wkt);
System.out.println("Long: "+centroid.getLon()+", Lat: "+centroid.getLat());
}
@Test
public void wktSND(){
String wkt="POLYGON ((15.0890347818947000 58.4016252063743000, 15.0886178984403000 58.4014150599049000, 15.0882593461811000 58.4012361894750000, 15.0877677533438000 58.4009725637710000, 15.0872345094368000 58.4006865934337000, 15.0867758097746000 58.4004629423839000, 15.0864339387892000 58.4002930037917000, 15.0860410894795000 58.4001448849296000, 15.0856568468080000 58.3999879707178000, 15.0852396416980000 58.3997954979955000, 15.0848901762974000 58.3995857184202000, 15.0845903412038000 58.3994204326843000, 15.0845492281592000 58.3993715645669000, 15.0846090823620000 58.3993276863909000, 15.0842983876037000 58.3992817208913000, 15.0842119123063000 58.3993917714065000, 15.0842685128493000 58.3995070502855000, 15.0845256073749000 58.3997030466499000, 15.0847657703784000 58.3999033684038000, 15.0850143573253000 58.4001037380030000, 15.0853219913347000 58.4003000162623000, 15.0857384794602000 58.4005278574010000, 15.0859303780227000 58.4006173677459000, 15.0862306820130000 58.4007605447592000, 15.0866902830228000 58.4009399884428000, 15.0870247289009000 58.4010612472058000, 15.0875181172298000 58.4012364553409000, 15.0879784504359000 58.4013805265811000, 15.0883964981257000 58.4015332008690000, 15.0886722704646000 58.4016408627805000, 15.0888306740171000 58.4017213377041000, 15.0890347818947000 58.4016252063743000))";
GeoPoint centroid = bu.calculateCentroid(wkt);
System.out.println("Long: "+centroid.getLon()+", Lat: "+centroid.getLat());
}
}