Problem with linestring

Could somebody advise me why the linestring behaves differently to the two lists as shown in the attached?

Label2 shows [[1.315,103.845],[1.316,103.846],[1.317,103.847]]
whereas Label1 shows [[1.32305,103.82732],[1.31584,103.83453]], the points of linestring indicated in designer.

I get a screen error with your Label1 values:

"Invalid value for point at index 1 (103.845, 1.315)."

The valid range of latitude in degrees is -90 and +90 for the southern and northern hemisphere respectively. Longitude is in the range -180 and +180 specifying coordinates west and east of the Prime Meridian, respectively.

For reference, the Equator has a latitude of 0°, the North pole has a latitude of 90° north (written 90° N or +90°), and the South pole has a latitude of -90°.

The Prime Meridian has a longitude of 0° that goes through Greenwich, England. The International Date Line (IDL) roughly follows the 180° longitude. A longitude with a positive value falls in the eastern hemisphere and negative value falls in the western hemisphere.

Thanks Tim.

You’re right. When I changed the list test1 to values within the allowable range, the label shows up the coordinates correctly.

I just do not understand why the AI Companion doesn’t indicate an error in the first instance.

Possibly goes by too quickly when the blocks are in Screen1.initialise

The label did show values of the PointsFromLinestring shown in the Designer, but no error msg from AI Companion.

I have another issue.

I set linestring1.points to the list variable lineLocation only if the list variable has more than one item. But why is there still an error saying the linestring1 requires at least 2 points and that there was none?

Attached are the blocks. Appreciate if anyone can help.

Thanks.

Here is an example showing how to use LineString

If you download the LineStringMap.aia example, does the example work?

A guess using these two blocks together is creating a problem.
linestringIssue

Either use Points or PointsFromString but not both.

Also have a look at some of the logic you have used in your locationChanged event:

image

image

Thanks Steve and Tim.

I tried using either LineString1.Points or LineString1.PointsFromString and in both instances it worked.

But for LineSting1.PointsFromString I have to set the block to a list consisting of pairs of values in the form of [latitude,longitude] and not [longitude,latitude] as mentioned to be required. Why is this so?

Also, since both LineString1.Points and LineString.PointsFromString achieve the same objective, why do we need to have two blocks? Are there circumstances where one works but not the other?

By the way, Steve, I have not tried the LineStringMap.aia because I’m unable to open the aia file after I downloaded it.

How could I open it?

Because the documentation for LineString has an error.. use latitude,longitude. MIT indicates the text will be corrected during the next AI2 release.

===================================================

Yes. Points takes a List as input. PointsFromString takes a list you construct as input like
" [[42.36907141773815,-71.10506057739259],[42.3637444694139,-71.09785079956056]] "

  • The two methods are there for flexibility.
    The PointsFromString is demonstrated in the example aia.
    ==================================================

Do this:

LoadAnaia

This will bring up import

Select the OK, that brings up anther screen you use to load the example Project in the Designer.

Thanks Steve for the steps on opening the aia files.

For the LineString.PointsFromString, I tried with List as input and it seems to work as well. Is this the way it is?

Thank you.

Hi,
I 'm trying to program an app where multiple users of the app can update their current locations so that everyone knows where everyone else is.

I tried to store the current latitude and longitude to the TinyWebDb and to be sure that the latitude and longitude values are correctly returned from the TinyWebDb I have introduced a label to verify this.

The label indicated that a list of latitude and longitude values were returned. However when I ran the AI Companion, I got the error message that said “Attempt to get item 2 of a list of length 1”. Where did I go wrong?

Appreciate your advice please.

Thank you.

Sorry, I forgot to download the blocks earlier.

Hi,
Is there any way to clear the items stored in TinyWebDb like the “clear TinyDb”?

Unfortunately not. All you can do is set the tags to blank / “”.

The AsteroidDB tinywebDB clone allows to Delete by Tag

The php server tinywebdb clone can be extended with some php to delete more

I created a “secure tinywebDB” which allows deletion of the database

Sorry, we do not know. You posted a few Blocks but not the important ones. You apparently tried to iterate through a List without checking if the length of list is at least two.

Thanks Steve.

I have managed to solve the problem by setting a list variable to valueFromWebDB before using the component select list item.

Thanks Tim for the info.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.