Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

creating lines in Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I`m completely new to Java and in big trouble with the following exercise.
Using JTS Topology Suite and Eclipse, I`m supposed to run a certain program to create 3 lines (LineString; a, b, c) with the coordinates (x,y) and as a result to find out which lines intersect the first line a.

This is what have:

I don`t know how I could create three separate lines, each line a, b and c has 3 pairs of x,y coordinates. I think here I am creating just one big line with all the coordinates.
If understand correctly this is the command that is actually taking x,y coordinates from above and joining it for a line, right?
Since I`m supposed to have 3 lines, should I amend it or copy 3x somehow?


Any help much appreciated!!!
 
Marshal
Posts: 68898
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have moved the questions out of the code tags. Your code looks all confused and will not compile in its current state. For example, you are using x and y before you declare them.
I am not familiar with JTS. You can find out how to draw lines in Swing/AWT with Graphics2D here.

I suggest you are making life dofficult for yourself by trying too much all at once. I suggest you hard‑code a few figures, and see what happens with one line.Now you should have a line. I do not know what the code to display this line or anything is.
Try that one line. Forget about command‑line input or intersection. Get that one line working. Then add more coordinates to your array and see what happens. I do not know what the code to display that line is, nor how to work out whether two lines intersect.
 
Campbell Ritchie
Marshal
Posts: 68898
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Earlier, I wrote: . . . . . .

I have looked up the JTS documentation and that should read (as you had it)
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic