Win a copy of Head First Go this week in the Go forum!

Greg Posey

+ Follow
since Mar 06, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Greg Posey

Console Output:

11 months ago
Any reason why this "poly.contains(lat1, lon1)" is always returning false?
lat1,lon1 is definitely inside the polygon.
11 months ago
Sorry if this is a poorly worded question.

I have the polygon coordinates for the below image. How would I take my current GPS position and figure out which polygon I am in?

1 year ago
Stephan, thanks for writing/finding that. I will have to spend some time to understand what is going on in that code.
1 year ago
I appreciate the insights you guys gave me. Definitely thankful for you putting up with me. im very new to JAVA and have a hard time asking the right questions.
1 year ago
This is my getterSetter class...well a snippet.

In nmea i initialized it with this line

Then in my gui, I was able to access it with

So my problem has been solved. I highly doubt my program conforms to proper java formats...but it is working ATM...although i do get sporadic parsing errors at times...
1 year ago
Lets say I have 4 classes:


I create a new instance of getterSetter in NMEA. NMEA parses string "nmea" and sets the values in the instance of getterSetter.
How would i access the instance of getterSetter in NMEA from GUI?
1 year ago

Paul Clapham wrote:

Greg Posey wrote:Can I make a method or a constructor that would make it available in another class?

But you would be passing that string to NMEA in the first place, via the getUpdatedStatus method. Or more accurately, you'd be passing a very similar string with a $ character at the front. So why don't you just hang onto it, rather than trying to get it back out of NMEA?

How else would I get the gps values(time, lat, long, velocity, etc) to my GUI class?
1 year ago

Stephan van Hulst wrote:You should probably create a class that encapsulates all the data of an NMEA sentence. The parsers should then return instances of this class. When you've parsed a sentence, pass it to a an object that's responsible for dispatching the sentence to the applicable GPS message handler method.

So in NMEA, create an instance of my getterSetter class and then access that instance of getterSetter in the gui?

1 year ago

Paul Clapham wrote:But that's a local variable in a method of the NMEA class. It only exists when the method is running and it isn't accessible to anything outside of NMEA.

I get that it is a local variable. Can I make a method or a constructor that would make it available in another class?
1 year ago

Paul Clapham wrote:

Greg Posey wrote:Is it possible to take the string "nmea" from class NMEA...

I looked all through that class, several times, and I don't see either a string with that constant value or a variable with that name. I even used the search in my browser and couldn't find such a thing. So could you review that question and clarify it?

1 year ago

should be

and then under the button1actionperformed, it should have three methods to execute/call:

1 year ago
This is a very simplified version of the GUI. Whipped it up in netbeans real quick.
Is it possible to take the string "nmea" from class NMEA and pass it to string "inputLine" in this class....or do I have to get it from SerialGps?

If someone could point me to some links that would help me, I would appreciate that.

1 year ago

Stephan van Hulst wrote:Welcome to CodeRanch!

Never use static fields for anything other than constants. You will very easily introduce bugs in your application if your classes can just pull application state out of thin air. When a method needs something that's not a constant and not part of the object state, pass it as a method argument. When an object needs something that's not a constant across multiple method calls, pass it as a constructor argument.

So the flow of events is:

In my GUI, I have a start GPS button.

I initialize the SerialGps class in my gui class.
The gps starts when "Start Gps" is clicked.

SerialGps creates a new instance of NMEA.
I need to get the nmea string from that instance of NMEA to my GUI class.

After that I have no idea what to do. Would I need a method? A constructor? I am clueless when it comes to the flow of java.
1 year ago
I have three classes that I am working with.
The first class opens the GPS and reads the data.
The second parses the data.
The third is going to be the parsed data in a GUI.

My question is how do I pass the global variable gpsData to classC from NMEA?

I am using code that I found online for the gps data.

It looks like the NMEA class is dependent on serialGps and serialGps is dependent on NMEA.

I need to pass the inputLine which sets the global variable "gpsData" contained in the NMEA class to a third class which will be my GUI.

This is the serialGps class


The NMEA class:


1 year ago