greptilian logo

IRC log for #friendlyjava, 2020-01-13

##friendlyjava on freenode

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

All times shown according to UTC.

Time S Nick Message
01:54 Jantz joined ##friendlyjava
05:25 mr_lou joined ##friendlyjava
09:38 Jantz joined ##friendlyjava
11:51 Jantz_ joined ##friendlyjava
12:11 Jantz joined ##friendlyjava
12:21 Jantz joined ##friendlyjava
14:00 aditsu joined ##friendlyjava
14:01 aditsu joined ##friendlyjava
14:24 mr_lou joined ##friendlyjava
17:08 Jantz joined ##friendlyjava
18:35 Al_nz1 joined ##friendlyjava
18:35 Al_nz1 morning
18:35 Al_nz1 anyone about
18:37 Al_nz1 anyone able to help please with a question I think related to types : https://stackoverflow.com/questions/59721950/type-error-converting-jts-to-geojson-with-feature
18:44 aditsu hi Al_nz1
18:46 aditsu still there?
18:47 aditsu you wrote "It does not accept a string", that is not true
18:48 aditsu the problem is the return type is not org.wololo.geojson.Geometry
18:48 Jantz joined ##friendlyjava
18:48 aditsu but rather org.locationtech.jts.geom.Geometry
18:55 Al_nz1 aditsu: is it?
18:56 aditsu yeah, that's what I can see both in the javadoc and in your screenshot
18:56 aditsu sorry, github source code not javadoc
18:56 Al_nz1 aditsu: I thought line 15 and 16, shows return read(json, null);
18:56 Al_nz1 is that not returning a json, null?
18:57 aditsu no, json and null are arguments to a read method
18:57 aditsu "returning a json, null" does not even make any sense
18:59 Al_nz1 aditsu: ok, lets break this down, and see where my understanding is wrong.
18:59 Al_nz1 public Geometry read(String json) {
18:59 aditsu ok
19:00 Al_nz1 that means return a Geometry object, and take in as a paramter String json ?
19:00 aditsu yes
19:00 Al_nz1 the next line :
19:00 Al_nz1 return read(json, null)
19:01 Al_nz1 that means the method retuns "read(json, null)" ?
19:01 aditsu basically, yes
19:01 aditsu not the string, but the result of calling the method
19:02 Al_nz1 aditsu: right, so what confuses me then, is the read method returns a result to itself when it returns read(json, null) ?
19:03 aditsu first of all, there are 4 different read methods there
19:03 aditsu you're looking at the first one
19:03 aditsu and the first one is calling the second one
19:04 aditsu if we could give them numbers, it would be something like: public Geometry read1(String json) { return read2(json, null); }
19:05 aditsu are you familiar with method overloading?
19:09 Al_nz1 brb
19:11 Al_nz1 sorry back
19:12 Al_nz1 aditsu: not really, but I am happy to go away and read up on it.
19:12 aditsu ok, it's basically multiple methods with the same name but different number or type of arguments
19:12 Al_nz1 i guess the take away point here, is that the return object I should look at is the one in the method declaration - not so much the return type?
19:12 Al_nz1 aditsu: ah ok
19:13 aditsu the return object is found in the return statement, the return type is in the method declaration
19:13 Al_nz1 so if I am trying to get a jts.geom to a geojson string i dont need a reader, I need a writer?
19:13 aditsu since the return object is the result of a method call in this case, its type will be the return type of the 2nd method
19:14 aditsu then it is converted to the return type of the first method, which happens to be the same type
19:15 aditsu hmm, I am not familiar with the library, but it's possible that you need a writer
19:15 Al_nz1 right.
19:15 Al_nz1 well the writer method at least returns what I want - which is a wololo.geojson object
19:17 aditsu btw, is "wololo" an AOE reference? :p
19:18 Al_nz1 whats AOE?
19:18 aditsu Age Of Empires, a game
19:18 aditsu see https://knowyourmeme.com/memes/wololo
19:21 Al_nz1 aditsu: ahh, I see. I dont know
19:22 Al_nz1 sooo, I am trying the writer now:
19:22 Al_nz1 https://gist.github.com/bigalnz/ba1cb1286cde917391892cd43a6da5d9
19:22 Al_nz1 but on line 23
19:24 Al_nz1 it complains that Feature(org.wololo.geojson.geometry, Map<String, Object>) in Feature cannot be applied to org.locationtech.jts.geom.point
19:24 Al_nz1 so I need to go and wee what the new Feature needs
19:25 aditsu that already says that it needs org.wololo.geojson.geometry for the first argument
19:27 Al_nz1 ok, I accept it says that, BUT if I didnt have the benefit of that error, I would go to the Feature class
19:27 Al_nz1 https://github.com/bjornharrtell/jts2geojson/blob/master/src/main/java/org/wololo/geojson/Feature.java
19:27 Al_nz1 to me it looks like a new Feature can accept Geometry and Map<String, Object>
19:28 Al_nz1 where in that Feature class however could I tell if Geometry is of type jts.geom or wololo.geom ?
19:28 aditsu oh, first you can look at the imports, but in this case it doesn't import any Geometry
19:29 aditsu then it must be in the same package as the Feature class
19:29 aditsu classes in the same package can be accessed directly by name
19:33 Al_nz1 ahh, ok. makes sense
19:36 Al_nz1 so i am getting there I think
19:38 Al_nz1 if I try this https://gist.github.com/bigalnz/3ff012cb445179fead670292ebc6cad8 look at line 26
19:38 Al_nz1 I need to get my jts.geom.point into a org.wololo.geom.geometry
19:39 Al_nz1 so if i look at https://github.com/bjornharrtell/jts2geojson/tree/master/src/main/java/org/wololo/geojson
19:39 Al_nz1 do I need a GeometryFactory instance to do the conversion?
19:40 aditsu I don't see any GeometryFactory there, but anyway, I don't know anything about that library
19:41 Al_nz1 sorry I mean GeoJsonFactory, it has a method that returns Geometry
19:41 aditsu I have no idea if that helps you or not
19:42 aditsu I just saw that org.wololo.geojson.Point extends Geometry, so maybe you're supposed to convert your Point to the other kind of Point?
19:43 Al_nz1 aditsu: exactly, but I am trying to work out how
19:43 aditsu there should be some documentation for the library
19:44 Al_nz1 are classes that have "Factory" in the name usually used for conversion?
19:44 Al_nz1 this is all I could find : https://github.com/bjornharrtell/jts2geojson/blob/master/README.md
19:44 aditsu not really, they are usually used for creating objects based on some kind of configuration
19:46 aditsu but this one may be used for conversion
19:48 Al_nz1 well the introduction in the readme says : This Java library can convert JTS geometries to GeoJSON and back.
19:48 Al_nz1 so it can do it, but how is what I am trying to figure out
19:48 aditsu I don't know what either of those things are :)
19:50 Al_nz1 well jts.geom is one type, wololo.geojson is another
19:50 aditsu it looks like GeoJSONReader and GeoJSONWriter both have multiple convert methods
19:51 aditsu try those
19:59 aditsu oh wait, they're not public! I think you're supposed to just use read/write
20:00 Al_nz1 I did
20:00 Al_nz1 I have got that part of the converison ok
20:00 aditsu I mean you can use read or write to convert your Point to the correct Geometry
20:01 aditsu I think it's read
20:02 Al_nz1 this worked :
20:02 Al_nz1 GeoJSONWriter writer = new GeoJSONWriter();
20:02 Al_nz1 org.wololo.geojson.Geometry geom = writer.write(p);
20:02 Al_nz1 where p is a jts.geom
20:02 aditsu oh ok
20:03 aditsu guess I "read" that wrong :p
20:03 Al_nz1 aditsu: yeah I was getting the reader and writer methods around the wrong way - guess it depends on which was you are looking at the conversion
20:04 aditsu those names are not very self-explanatory...
20:05 Al_nz1 brb - need to get coffee :-)
20:56 Al_nz1 joined ##friendlyjava
20:57 Al_nz1 back
21:00 Al_nz1 aditsu: I like the name of this channel
21:01 Al_nz1 some of the regulars on #java are arrogant pricks
21:01 aditsu me too :)
21:04 Al_nz1 where abouts in the world are you located
21:04 pdurbin Boston
21:04 aditsu I'm in Hong Kong
21:05 Al_nz1 ahh, its earlyt there!!!
21:05 aditsu or late, depending on your perspective :p
21:53 Jantz joined ##friendlyjava
22:22 Jantz joined ##friendlyjava
23:27 Al_nz1 joined ##friendlyjava
23:35 aditsu joined ##friendlyjava

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

##friendlyjava on freenode