Locus Map - forum

Development => Developers => Topic started by: menion on November 09, 2012, 11:29:33

Title: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on November 09, 2012, 11:29:33
Hi to all,

API location: http://code.google.com/p/android-locus-map/ (http://code.google.com/p/android-locus-map/)

  together with huge changes in database system in Locus version 2.7.0, come another expected change. I'm glad I may anounce new version of Locus API. Locus internally for points/tracks/locations etc. use new objects, that are shared also with new Locus API. Current, first version of API, now have completely same functionality as old one, except few details.

9. 11. 2012
Do not use current version of API in public version of your application. API need to be well tested and also improved by developers needs. Comments how to do things in API different or better are welcome. So use it, test it and let me know.

Conversion from deprecated version of API is possible. Some functions have now more logical names and are placed in more logical hierarchy. Best methods are to check samples in sample application
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: ville_sml on January 20, 2014, 19:32:28
In the new api, is there a possibility to remove a temporary point/track?

There is method listed:
protected static boolean removeDataSilently(Context ctx, String extraName,
         ArrayList<Integer> itemsId) throws RequiredVersionMissingException;
But is this the correct way? If so, should the ArrayList<Integer> itemsId be ArrayList<Long> itemsId as the GeoData has field:
    // unique ID of this object
   public long id;

Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on January 21, 2014, 08:45:34
hi,
  function you found is currently used only for removing circles from map, not generally on all possible map items. I have improved documentation to make this clear.

  What you need is already possible, anyway to make it easier, I just added new function

Code: [Select]
ActionDisplayPoints.removePackFromLocus(Context ctx, String packName)
that should do what you need. It's already on Google Code repository, so you may try it. Hope it will work fine
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 13, 2014, 21:19:42
Hi menion,

as you know, I'm trying to rewrite Geoget addon to new API. This error occured after canceling the addon:
http://prntscr.com/2s6t9y

I don't know whether is my code OK or not, maybe you will know better. :-)
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 13, 2014, 21:27:54
Hi,
 
if you see this error, it have to mean, that your compiled project do not have included Locus API library (the core).

This may happen probably only in case, you included project for compiling, but not included also to deploy.

Did you follow exactly steps on this page? http://code.google.com/p/android-locus-map/wiki/Installation

Check mainly
 - locus-api-android - step 2
 - your project (same as locus-api-android-sample) - also step 2

important is mainly "check also LocusAPI"
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 13, 2014, 22:46:58
I have checked it four time and for the five time also together with my girlfriend. Everything is checked and added. I tried to put LocusAPI to the top of the "order and export" list but it has no effect.

Sample project does the same.

The only difference from the described setup is that I didn't use Mercurial and downloaded it directly from the google code.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 14, 2014, 08:50:50
[CZ]
No pak by jsi mohl ještě zkusit do LocusAPI_android a toho tvého projektu přidat přímo LocusAPI.jar (z přílohy), namísto linkování knihovny.

Eclipse občas nedělá dobrotu, nicméně vyčištění projektů případně restart eclipse většinu problémů vyřeší ..
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 14, 2014, 13:15:19
[CZ]
Bohužel nepomohlo, zkusím to celé naklikat znova...

edit
Ještě přiložím tuto chybu: http://prntscr.com/2scsp6

Screeny nastavení hlavního projektu (MainActivity se jmenuje): http://prntscr.com/2sczgg

V LocusAPI_android mám zatržené "Is Library", "Project Build Target" stejně jako výše, v Java Build Path/Projects není nic, do Libraries jsem přidal externí JAR LocusAPI, v Order and Export je zatržené.

Builduju to přes pravý klik na MainActivity project a Run as -> Android Application.

V telefonu mám poslední verzi legální Pro verze, systém 2.3.3.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 14, 2014, 14:04:33
[CZ]
no já ti nevím :)

můžeš mi ten balíček do Eclipse nějak poslat, já se na to podívám u sebe? Pokud to co na screenshotu máš červeně přeškrtnuté, tam opravdu nemáš, tak to vypadá v pořádku.

Ta chyba co vidíš (první screen) vůbec nevím co znamená. Tam žádné LocusAPI_android.apk být nemá. Ta knihovna se ti má zkompilovat do tvého projektu rovnou a ne přes nějaké APK.

No to jsem zvědav co to nakonec bude. Vypadá že použití API budu muset nějak zjednodušit, i když zatím nevím jak protože tohle nic komplikovaného být nemá :)
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 16, 2014, 12:00:42
I'll change language back to English, to keep topic readable for others also ...

So I create new Workspace, imported your two projects with File > Import > Existing project

In both projects, I fixed problem with absolute path to library LocusAPI

And after that, no problem to start and to run this project!

BUT: Seems you switched from old API to new, but not all! In manifest file is receiver for broadcast messages. This needs to be set to

 
Code: [Select]
           <intent-filter>
                <action android:name="locus.api.android.ACTION_PERIODIC_UPDATE" />
            </intent-filter>

you have there set old parameter.

It's weird that you saw some completely different error message, but this may solve that problems
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 17, 2014, 14:38:29
Is it possible that problem is in old (not latest) version of ADT bundle? I have just downloaded the latest one and now everything seems working...

(The video I sent to you is with the previous version)
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 17, 2014, 15:37:56
possible is everything, but I see no reason for this.

Anyway really do not forget to change parameter in manifest. Good it works now ...
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 20, 2014, 21:16:04
I have question, how Locus recognizes that cache (during import) is computed and moves it to final coords? (checkbox in Locus is checked)

And another question: It seems that in field GeocachingWaypoint.desc can be HTML tags but when I edit that WP I see HTML tags - is it expected behavior?
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 21, 2014, 07:39:22
1) cache is computed if:
Code: [Select]
waypoint.gcData.computed = true;
or cache contains waypoint that starts with "fi", "fl"  and it's coordinates are non-zero

2) yes, all these descriptions may contain HTML code and Locus display them in WebView view so they will look exactly as should! Negative effect is, that if fiels, like "desc" is editable, you see all these HTML tags. Anyway in case of caches, I think there is no need to put anything to waypoint.desc. Rather use waypoint.gcData.setShortDescription() and waypoint.gcData.setLongDescription() functions
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 21, 2014, 22:25:58
Ad 1) So, during the reading from geoget database, I can detect cache with final waypoint in two ways - according the type of waypoint (GeocachingWaypoint.CACHE_WAYPOINT_TYPE_FINAL) and according to waypoint's flag (http://geoget.ararat.cz/doku.php/user:databaze#struktura_databaze_geogetu - see table "waypoint" and column "flag").
What should I do so user with checked "move to final coords" will see red star in the corner and icon on final coords?

Is setting GeocachingWaypoint.type = GeocachingWaypoint.CACHE_WAYPOINT_TYPE_FINAL not enough?
Would be condition
Code: [Select]
if (GeocachingWaypoint.type == GeocachingWaypoint.CACHE_WAYPOINT_TYPE_FINAL || flag == 2){
    gcData.computed = true;
}
enough?

BTW FYI, final waypoints are in Geoget with prefix Fx, where x = {0, 1, 2, 3, 4, ...}.

[CZE for better understanding :-)]
Mám v databázi Geogetu staženou keš přes API, u které mám přepsané souřadnice na webu. V geogetu tedy vidím nový WP a to: Prefix=F0, Druh=Final Location, Název=Coordinate Override, Flag=2 a nenulové souřadnice.

Momentálně v addonu testuji onen flag a pokud je 2, tak nastavuji gcData.computed = true; a nic víc. V Locusu potom po importu vidím ikonku na výchozích souřadnicích s hvězdičkou. Když jsem u jiné keše změnil pouze prefix z F0 na FI, flag zůstal 2, tak se nic nezměnilo. Pokud změním prefix z F0 na FI a zároven změním flag na 0 (to dělá GG automaticky při editaci), tak mám keš přesunutou na nové souřadnice, ale je bez hvězdičky.

Není mi tedy jasné, co musím a jak nastavit, aby byl výsledek ten, že keš bude na nových souřadnicích a zároven bude mít hvězdičku. Z tvé poslední odpovědi mi není jasné, jestli keš ohvězdičkuje Locus sám, když narazí na WP s prefixem FI.

Takže abych to shrnul, jak musí být nastaveny hodnoty, aby mohl být proveden přesun a přidána hvězdička?
[EN]To sum it up, how to set these fields so that Locus can move the cache and add red star to its icon?
GeocachingWaypoint.type = ?
GeocachingWaypoint.code = ?
GeocachingWaypoint.name = ?
Waypoint.gcData.computed = ?
something else = ?

Ad 2) In this description could be information from listing such as "Parkovani u Nemojanskeho mlyna" from listing http://coord.info/GC3JK82. In geoget, there is also another field for your own personal note, such as code to lock at final coords and I have been asked whether is it possible to import this information into Locus. So I add this personal note right behind the owner's note.

Thank you in advance! :-)
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 24, 2014, 18:48:56
Another minor problem:
I'm setting fields "dateCreated" and "lastUpdated" in class GeocachingData and no matter what I set, I see actuall date and time when I click on a cache in field "Created:" and no field "Updated:".

I think, that information about update could be important to know how old are data in listing and so on. In my case (importing from Geoget) would by lastUpdated date before dateCreated.

I have taken a look into your sample project, but you don't work with these dates so it doesn't answer my questions.

Thank you.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on February 25, 2014, 11:15:57
so

1) best is to set new cache coordinates to computed and set parameter "computed" to "true"

or you may as I wrote, add new waypoint that starts with 'FI'nal text. When Locus during import find such waypoint, it move cache to waypoint coordinates and also mark cache as computed automatically. So just simply try attach final waypoint to cache and check if Locus works correctly. It should

So parameters ...
simply add new waypoint. Locus test it's code by this function

Code: [Select]
private static boolean isFinalWaypoint(String testText) {
// check text
if (TextUtils.isEmpty(testText)) {
return false;
}

// decide if start as final waypoint
testText = testText.toLowerCase();
return testText.startsWith("fi") || testText.startsWith("fl");
}

or in description is just text "Coordinate Override"

If you want to improve this system, just let me know

ad 2) to add notes to cache or read users notes (there were also logical requests to synchronize users notes edited in Locus, back to GeoGet)

waypoint.gcData.getNotes(), setNotes()

ad 3) about times - I'm now worried, that these times are not used in Locus. Every Waypoint has own field "timeCreated" (it's in GeoData.timeCreated) which is used as main visible time. When you will have some working add-on, let me know, send me it for test and I'll fix this problem, so Locus will correctly display these values
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: petulinka1 on February 25, 2014, 20:01:55
The problem is, you're testing prefix, but you should test waypoint TYPE! Prefix can be WW, if I chose it... But WP type is the first thing, which decides, what WP is it.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on February 25, 2014, 21:58:55
I have to agree with Petulinka1, only waypoint type is significant and unambiguous. Everything else is quite unpredictable. :-)

To the second point - you are talking about personal note to whole cache, not only waypoint. See attached screenshot (from new addon's version). After the bold text is personal note only for this WP (before the bold text is owner's description). So, I have solved this issue and "no action needed" now. But if you want, you can add field to Locus for clear handling these personal notes. :)

Ad 3: That explain a lot. :-) When I update cache with GC4Locus addon I see "Last update" field (see attachment), so, it is obviously possible to set this value.
I set it in this way:
Code: [Select]
Date date = new Date();
gcData.dateCreated = date.getTime();
gcData.lastUpdated = c.getLong(c.getColumnIndex("dtupdate2"));
Current beta version is downloadable from http://www.voldik.cz/geo/locus/LocusAddonGeoget.apk.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Raddino on March 03, 2014, 21:26:19
Totally agree with Voldik and Petulinka. It should be recognized by type of WP, not by name or prefix. It will be nice to change it. Thanks

Odesláno z mého Nexus 5 pomocí Tapatalk

Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 04, 2014, 20:53:26
fine, so caching waypoints by type is now fixed. Thanks

about times - I see, there are three types of times in GeocachingData
Code: [Select]
/* time of last updated time (long since 1.1.1970 in ms) */
public long lastUpdated;
/* String with date of last exported - groundspeak:exported */
public long dateCreated;
/* String with date of hidden - value from CachePrinter */
public long hidden;

which you wanna see in Locus?

btw. because there will be more to discuss, it should be fine to create a czech topic for this ;)
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 10, 2014, 22:05:28
Is it possible to set elevation to GeocachingData? (I suppose it is not, so: Would it be possible to add this ability to API?) :-)

And once again thank you for previous work.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 13, 2014, 07:57:34
hmm I'm thinking about it and see no simple solution.

How you image it, as a function that allows you to get computed altitude based on coordinates or an ability to "fill altitude" automatically to points send to Locus?

Because I would like to create first option more, which gives quite a freedom to you or other developers, on second side, it will be slower because you will have to firstly ask locus for altitudes
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 13, 2014, 08:29:36
No no, I mean just simple method GeocachingData.setElevation(float elevation); In my case (import from Geoget), I already have the elevation computed.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 13, 2014, 08:52:33
ah just set elevation to point? Hmm all values realted to location are in waypoint location object

waypoint.getLocation().set ...
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 13, 2014, 09:31:24
Thank you, it's working. :-)
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 26, 2014, 13:10:25
I've found possible bug. When I use LocusUtils.handleIntentMainFunction(intent, new LocusUtils.OnIntentMainFunction() {...} I'm getting NullPointerException(). I thought it is bug in my application but when I run your sample application I get the same error. StackTrace is here: http://i.imgur.com/SKcqyxO.png

In your MainActivity it is line 230.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 27, 2014, 09:59:46
Sorry, I'm unable to find it.

What you do to achieve same problem? What you wrote about should apper when I install Locus API sample and then in Locus > menu > more > tap on MainActivity. But this works fine and Locus API sample appear and display result of this action.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 27, 2014, 10:31:54
Yes, it's working (as far I can tell).

The NullPointerException is thrown at line 422 in LocusUtils.java in method public static Location getLocationFromIntent(Intent intent, String intentExtra) {}

I add Sample App to the right panel, then click on it.
I've tried two different devices and also 'niximor' has reported me this bug.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 27, 2014, 10:36:54
Hmm it's weird. I'm unable to simulate it.

If this problem happen to you and you have access to source of Locus API, check please where this error happen (check if you have latest API). Because you wrote line 422, but on this line if function that creates location from Intent, but this line is in try/catch block

Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 27, 2014, 10:47:17
Yes, you are right, the exception is cought. Intent is not null, so I suppose that is it thrown in Location() constructor. Unfortunately I'm using LocusAPI.jar so I don't have its source code.

Do you use real device or emulator?
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 27, 2014, 11:20:12
only real device. I have some problems with emulators, so I don't use them at all

You use Jar file from here http://code.google.com/p/android-locus-map/downloads/list ? I remember there were some problems with it right? Because if so, this JAR is more then year old and I highly recommend to use latest source code for API
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: Voldik on March 27, 2014, 11:30:48
I use Jar file you sent me recently. I'll try the source code.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on March 27, 2014, 11:33:30
damn, it should be fine then.

Anyway I'm unable to simulate this. If it happen with your addon always, I'll try it with it also
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: berkley on July 12, 2014, 20:18:09
Hi,
can't import Locus_API wether to Eclipse nor to Android Studio. Locus_API_android works fine.
Couldn't figure out a problem.
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on July 13, 2014, 20:50:35
Hello Matthias,

hope this helps you http://docs.locusmap.eu/doku.php?id=manual:locus_api:installation

If there will be any problem, write me and I'll improve this manual
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: berkley on July 14, 2014, 11:15:43
Thanks, I'll give it a try on the next rainy day :-)
You don't want to create a jar file every time you publish changes?
Title: Re: [DEV] - Locus API (since Locus 2.7.3)
Post by: menion on July 14, 2014, 13:08:55
Sure, you're welcome.

And no, I see no reason for this. Also Jar files are possible for simple java libraries like Locus API, but for Android library project like Locus API - Android it's not possible to create simple jar file. It's required to import it as a whole library to your project.