[android-developers] Re: MapView Overlay problem

2011-07-02 Thread Felix Garcia Lainez
Ok thanks! I will take a look..

On 1 jul, 17:34, Kostya Vasilyev kmans...@gmail.com wrote:
 TraceView and dmtracedump:

 http://developer.android.com/guide/developing/debugging/debugging-tra...

 01.07.2011 19:26, TreKing ?:



      How should i profile this case? Really as i said there is not
      any strange thing on the code... Simply a map with an overlay...

  No idea. Look at the tools section in the docs and see what's
  available to you. I *think* there some kind of profiling tool, but I
  don't know for sure. If nothing else, you can throw a crude profiler
  together fairly easily to track how long a given block of code takes.

 --
 Kostya Vasilyev

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: MapView Overlay problem

2011-07-01 Thread Felix Garcia Lainez
Hi,

So you are doing something similar to my draw method?

I have just tested without alpha and anti-alising and it is faster,
but when there is big zoom level the mapactivity is closed (i think
this is due to memory usage)

How should i profile this case? Really as i said there is not any
strange thing on the code... Simply a map with an overlay...

Thanks!


On 1 jul, 01:39, TreKing treking...@gmail.com wrote:
 On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez 

 fgarcialai...@gmail.com wrote:
  About the size with 300 or 400 GeoPoints i am already having problems...
  The method isOnePointVisible is an optimization i did in order to try to
  improve performance (seems to work fine).

 So I have a very similar overlay to draw routes, with no optimization, and I
 just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

 Here are some thoughts:
 - What device are you running on?
 - Are you debugging or is this in release mode?
 - Do you need anti-aliasing? I think that might slow it down.
 - Do you need alpha? That would definitely slow down drawing. Set that to
 solid and see if if helps.

 If none of that helps you're going to have to profile your code to get a
 clear picture of what's taking so long.

 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: MapView Overlay problem

2011-07-01 Thread Felix Garcia Lainez
Ok it sounds good... The problem is that i don't know what initial
value to use for tolerance parameter... What would you recommend? 5
meters?

Thanks!

On 1 jul, 03:41, JP joachim.pfeif...@gmail.com wrote:
 I haven't had to use the Douglas-Peucker algorithm, but I understand
 others have so with 
 success.http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_al...
 This algorithm will thin out the number of poly lines.
 Apparently there's an open source implementation in the Android
 MyTracks app, licensed under Apache 
 2.0.http://code.google.com/p/mytracks/source/browse/MyTracks/src/com/goog...
 It's in the method decimate().
 JP

 On Jun 30, 2:46 pm, Felix Garcia Lainez fgarcialai...@gmail.com
 wrote:



  Hello,

  The case is that i want to show a route on a MapView. Something simple
  at first sight, simply i created a class that extends overlay and
  implement draw method. On this method i iterate over an array of
  GeoPoints and using a canvas y connect all points. It works fine more
  or less, but i am having issues when drawing long routes with many
  points. The problem is that application is very slow, and sometimes
  MapActivity is closed simply doing a zoom in or zoom out on the map
  with the route drawn...

  My question is how to improve performance on this situation

  Thanks!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: MapView Overlay problem

2011-07-01 Thread JP

You could conceivably use a change in zoom level to drive the thinning
of the poly lines, or other factors that help you determine the level
of thinning. This is not trivial - you'll want to run the algorithm
outside of your Overlay.draw() and probably not draw any lines until
the algorithm has finished. Off the cuff, I figure you'll have to use
AsyncTask for that, so there's not quick and dirty way (that I can
see) if you want to get this right. In any case, you could study
MyTracks to find out how they've solved this problem.


On Jul 1, 2:00 am, Felix Garcia Lainez fgarcialai...@gmail.com
wrote:
 Hi,

 So you are doing something similar to my draw method?

 I have just tested without alpha and anti-alising and it is faster,
 but when there is big zoom level the mapactivity is closed (i think
 this is due to memory usage)

 How should i profile this case? Really as i said there is not any
 strange thing on the code... Simply a map with an overlay...

 Thanks!

 On 1 jul, 01:39, TreKing treking...@gmail.com wrote:







  On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez 

  fgarcialai...@gmail.com wrote:
   About the size with 300 or 400 GeoPoints i am already having problems...
   The method isOnePointVisible is an optimization i did in order to try to
   improve performance (seems to work fine).

  So I have a very similar overlay to draw routes, with no optimization, and I
  just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

  Here are some thoughts:
  - What device are you running on?
  - Are you debugging or is this in release mode?
  - Do you need anti-aliasing? I think that might slow it down.
  - Do you need alpha? That would definitely slow down drawing. Set that to
  solid and see if if helps.

  If none of that helps you're going to have to profile your code to get a
  clear picture of what's taking so long.

  --- 
  --
  TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
  transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: MapView Overlay problem

2011-07-01 Thread Felix Garcia Lainez
Ok thank you. I will try to see how they do this.

On 1 jul, 15:49, JP joachim.pfeif...@gmail.com wrote:
 You could conceivably use a change in zoom level to drive the thinning
 of the poly lines, or other factors that help you determine the level
 of thinning. This is not trivial - you'll want to run the algorithm
 outside of your Overlay.draw() and probably not draw any lines until
 the algorithm has finished. Off the cuff, I figure you'll have to use
 AsyncTask for that, so there's not quick and dirty way (that I can
 see) if you want to get this right. In any case, you could study
 MyTracks to find out how they've solved this problem.

 On Jul 1, 2:00 am, Felix Garcia Lainez fgarcialai...@gmail.com
 wrote:



  Hi,

  So you are doing something similar to my draw method?

  I have just tested without alpha and anti-alising and it is faster,
  but when there is big zoom level the mapactivity is closed (i think
  this is due to memory usage)

  How should i profile this case? Really as i said there is not any
  strange thing on the code... Simply a map with an overlay...

  Thanks!

  On 1 jul, 01:39, TreKing treking...@gmail.com wrote:

   On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez 

   fgarcialai...@gmail.com wrote:
About the size with 300 or 400 GeoPoints i am already having problems...
The method isOnePointVisible is an optimization i did in order to try to
improve performance (seems to work fine).

   So I have a very similar overlay to draw routes, with no optimization, 
   and I
   just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

   Here are some thoughts:
   - What device are you running on?
   - Are you debugging or is this in release mode?
   - Do you need anti-aliasing? I think that might slow it down.
   - Do you need alpha? That would definitely slow down drawing. Set that to
   solid and see if if helps.

   If none of that helps you're going to have to profile your code to get a
   clear picture of what's taking so long.

   ---
--
   TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
   transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread TreKing
On Fri, Jul 1, 2011 at 4:00 AM, Felix Garcia Lainez fgarcialai...@gmail.com
 wrote:

 So you are doing something similar to my draw method?


Yup - nearly identical. What I don't do is use anti-aliasing (unless it's on
be default, I don't know) or alpha. I also only use moveTo() once (first
point) and then lineTo() thereafter. I can't imagine that would make much of
a difference.


 I have just tested without alpha and anti-alising and it is faster,
 but when there is big zoom level the mapactivity is closed (i think
 this is due to memory usage)


Use LogCat and the debugger to make sure.

How should i profile this case? Really as i said there is not any strange
 thing on the code... Simply a map with an overlay...


No idea. Look at the tools section in the docs and see what's available to
you. I *think* there some kind of profiling tool, but I don't know for sure.
If nothing else, you can throw a crude profiler together fairly easily to
track how long a given block of code takes.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread Kostya Vasilyev

TraceView and dmtracedump:

http://developer.android.com/guide/developing/debugging/debugging-tracing.html

01.07.2011 19:26, TreKing ?:


How should i profile this case? Really as i said there is not
any strange thing on the code... Simply a map with an overlay...


No idea. Look at the tools section in the docs and see what's 
available to you. I *think* there some kind of profiling tool, but I 
don't know for sure. If nothing else, you can throw a crude profiler 
together fairly easily to track how long a given block of code takes.


--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2011-07-01 Thread Felix Garcia Lainez
I have improved the responsiveness using some of MyTrack approaches,
but i am still getting this exception, simply doing zoom in and zoom
out sometimes

java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:574)
at com.google.android.maps.ZoomHelper.createSnapshot(ZoomHelper.java:
444)
at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:151)
at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:140)
at com.google.android.maps.MapView.doZoom(MapView.java:1478)
at com.google.android.maps.MapView.doZoom(MapView.java:1487)
at com.google.android.maps.MapView$6.onZoom(MapView.java:1442)
at android.widget.ZoomButtonsController
$3.onClick(ZoomButtonsController.java:268)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8817)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

On 1 jul, 15:49, JP joachim.pfeif...@gmail.com wrote:
 You could conceivably use a change in zoom level to drive the thinning
 of the poly lines, or other factors that help you determine the level
 of thinning. This is not trivial - you'll want to run the algorithm
 outside of your Overlay.draw() and probably not draw any lines until
 the algorithm has finished. Off the cuff, I figure you'll have to use
 AsyncTask for that, so there's not quick and dirty way (that I can
 see) if you want to get this right. In any case, you could study
 MyTracks to find out how they've solved this problem.

 On Jul 1, 2:00 am, Felix Garcia Lainez fgarcialai...@gmail.com
 wrote:



  Hi,

  So you are doing something similar to my draw method?

  I have just tested without alpha and anti-alising and it is faster,
  but when there is big zoom level the mapactivity is closed (i think
  this is due to memory usage)

  How should i profile this case? Really as i said there is not any
  strange thing on the code... Simply a map with an overlay...

  Thanks!

  On 1 jul, 01:39, TreKing treking...@gmail.com wrote:

   On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez 

   fgarcialai...@gmail.com wrote:
About the size with 300 or 400 GeoPoints i am already having problems...
The method isOnePointVisible is an optimization i did in order to try to
improve performance (seems to work fine).

   So I have a very similar overlay to draw routes, with no optimization, 
   and I
   just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

   Here are some thoughts:
   - What device are you running on?
   - Are you debugging or is this in release mode?
   - Do you need anti-aliasing? I think that might slow it down.
   - Do you need alpha? That would definitely slow down drawing. Set that to
   solid and see if if helps.

   If none of that helps you're going to have to profile your code to get a
   clear picture of what's taking so long.

   ---
--
   TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
   transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread TreKing
On Fri, Jul 1, 2011 at 11:29 AM, Felix Garcia Lainez 
fgarcialai...@gmail.com wrote:

 I have improved the responsiveness using some of MyTrack approaches,
 but i am still getting this exception, simply doing zoom in and zoom
 out sometimes


I doubt there's much you can do about that - the Maps library is notoriously
buggy. I've lost count of how many workarounds I've had to employ to get it
to behave *most of the time* - and I still get the occasional crash from it
when users do crazy things like zoom or pan.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2011-07-01 Thread JP

The stack trace does not include any calls to your code. I suspect it
has to do with the loading of map tiles. Nothing you can do that I
know of. I am seeing this for years now, but not at an alarming clip.
How time flies... Anyway, it would be lovely to learn about this some
more. Perhaps TreKing or someone else who's more involved can weight
in on this with some more insight.
As a side note, I never bothered to check, I'm sure this problem has a
record in some issues database already, where you could push a button
or star.


On Jul 1, 9:29 am, Felix Garcia Lainez fgarcialai...@gmail.com
wrote:
 I have improved the responsiveness using some of MyTrack approaches,
 but i am still getting this exception, simply doing zoom in and zoom
 out sometimes

 java.lang.OutOfMemoryError: bitmap size exceeds VM budget
         at android.graphics.Bitmap.nativeCreate(Native Method)
         at android.graphics.Bitmap.createBitmap(Bitmap.java:574)
         at com.google.android.maps.ZoomHelper.createSnapshot(ZoomHelper.java:
 444)
         at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:151)
         at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:140)
         at com.google.android.maps.MapView.doZoom(MapView.java:1478)
         at com.google.android.maps.MapView.doZoom(MapView.java:1487)
         at com.google.android.maps.MapView$6.onZoom(MapView.java:1442)
         at android.widget.ZoomButtonsController
 $3.onClick(ZoomButtonsController.java:268)
         at android.view.View.performClick(View.java:2408)
         at android.view.View$PerformClick.run(View.java:8817)
         at android.os.Handler.handleCallback(Handler.java:587)
         at android.os.Handler.dispatchMessage(Handler.java:92)
         at android.os.Looper.loop(Looper.java:144)
         at android.app.ActivityThread.main(ActivityThread.java:4937)
         at java.lang.reflect.Method.invokeNative(Native Method)
         at java.lang.reflect.Method.invoke(Method.java:521)
         at com.android.internal.os.ZygoteInit
 $MethodAndArgsCaller.run(ZygoteInit.java:868)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
         at dalvik.system.NativeStart.main(Native Method)

 On 1 jul, 15:49, JP joachim.pfeif...@gmail.com wrote:







  You could conceivably use a change in zoom level to drive the thinning
  of the poly lines, or other factors that help you determine the level
  of thinning. This is not trivial - you'll want to run the algorithm
  outside of your Overlay.draw() and probably not draw any lines until
  the algorithm has finished. Off the cuff, I figure you'll have to use
  AsyncTask for that, so there's not quick and dirty way (that I can
  see) if you want to get this right. In any case, you could study
  MyTracks to find out how they've solved this problem.

  On Jul 1, 2:00 am, Felix Garcia Lainez fgarcialai...@gmail.com
  wrote:

   Hi,

   So you are doing something similar to my draw method?

   I have just tested without alpha and anti-alising and it is faster,
   but when there is big zoom level the mapactivity is closed (i think
   this is due to memory usage)

   How should i profile this case? Really as i said there is not any
   strange thing on the code... Simply a map with an overlay...

   Thanks!

   On 1 jul, 01:39, TreKing treking...@gmail.com wrote:

On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez 

fgarcialai...@gmail.com wrote:
 About the size with 300 or 400 GeoPoints i am already having 
 problems...
 The method isOnePointVisible is an optimization i did in order to try 
 to
 improve performance (seems to work fine).

So I have a very similar overlay to draw routes, with no optimization, 
and I
just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

Here are some thoughts:
- What device are you running on?
- Are you debugging or is this in release mode?
- Do you need anti-aliasing? I think that might slow it down.
- Do you need alpha? That would definitely slow down drawing. Set that 
to
solid and see if if helps.

If none of that helps you're going to have to profile your code to get a
clear picture of what's taking so long.

---
 --
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: MapView Overlay problem

2011-07-01 Thread TreKing
On Fri, Jul 1, 2011 at 12:26 PM, JP joachim.pfeif...@gmail.com wrote:

 As a side note, I never bothered to check, I'm sure this problem has
 a record in some issues database already, where you could push a button or
 star.


As a matter of fact ...
http://code.google.com/p/android/issues/detail?id=3405q=map%20view%20out%20of%20memorycolspec=ID%20Type%20Status%20Owner%20Summary%20Stars

2 years old. Given the state of the Google Maps Library, I would not hold my
breath.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2011-06-30 Thread Felix Garcia Lainez
I use this code:

public class PolylineOverlay extends Overlay
{
private ArrayListGeoPoint polyline; // Contains set of points to be
connected.
private Paint pathPaint = null; // Paint tool that is used to draw
on the map canvas.

public PolylineOverlay(ArrayListGeoPoint polyline, int color)
{
this.polyline = new ArrayListGeoPoint(polyline);

this.pathPaint = new Paint();
this.pathPaint.setAntiAlias(true);
this.pathPaint.setStrokeWidth(4);
this.pathPaint.setColor(color);
this.pathPaint.setAlpha(120);
this.pathPaint.setStyle(Paint.Style.STROKE);
}

@Override
public void draw(Canvas canvas, MapView mView, boolean shadow)
{
if(!shadow)
{
if(polyline != null)
{
Projection projection = mView.getProjection();
Path routePath = new Path();

Point prevPoint = null;

//Add each point to the routePath.
for(GeoPoint inPoint : polyline)
{
Point outPoint = null;
outPoint = projection.toPixels(inPoint, 
outPoint);

if(polyline.indexOf(inPoint) == 0)
routePath.moveTo(outPoint.x, 
outPoint.y);
else
{
if(isOnePointVisible(prevPoint, 
outPoint, mView))
{

routePath.moveTo(prevPoint.x, prevPoint.y);

routePath.lineTo(outPoint.x, outPoint.y);
}
}

prevPoint = outPoint;
}

canvas.drawPath(routePath, pathPaint);
}
}

super.draw(canvas, mView, shadow);
}

private boolean isOnePointVisible(Point point, Point point2,
MapView mapView)
{
return (point.x  0  point.x  mapView.getWidth()  point.y 
0  point.y  mapView.getHeight()) ||
(point2.x  0  point2.x  mapView.getWidth()  point2.y  0
 point2.y  mapView.getHeight());
}

@Override
public boolean onTap(GeoPoint p, MapView mapView) {
// Handle tapping on the overlay here
return false;
}
}

About the size with 300 or 400 GeoPoints i am already having
problems... The method isOnePointVisible is an optimization i did in
order to try to improve performance (seems to work fine).

Thanks!

On 1 jul, 00:16, TreKing treking...@gmail.com wrote:
 On Thu, Jun 30, 2011 at 4:46 PM, Felix Garcia Lainez 

 fgarcialai...@gmail.com wrote:
  On this method i iterate over an array of GeoPoints and using a canvas y
  connect all points.

 What's your actual code?

  It works fine more or less, but i am having issues when drawing long routes
  with many points.

 Define long routes and many points.

 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: MapView Overlay problem

2011-06-30 Thread TreKing
On Thu, Jun 30, 2011 at 5:47 PM, Felix Garcia Lainez 
fgarcialai...@gmail.com wrote:

 About the size with 300 or 400 GeoPoints i am already having problems...
 The method isOnePointVisible is an optimization i did in order to try to
 improve performance (seems to work fine).


So I have a very similar overlay to draw routes, with no optimization, and I
just loaded 7 or 8 of them with no apparent slow down on my Nexus One.

Here are some thoughts:
- What device are you running on?
- Are you debugging or is this in release mode?
- Do you need anti-aliasing? I think that might slow it down.
- Do you need alpha? That would definitely slow down drawing. Set that to
solid and see if if helps.

If none of that helps you're going to have to profile your code to get a
clear picture of what's taking so long.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2011-06-30 Thread JP
I haven't had to use the Douglas-Peucker algorithm, but I understand
others have so with success.
http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
This algorithm will thin out the number of poly lines.
Apparently there's an open source implementation in the Android
MyTracks app, licensed under Apache 2.0.
http://code.google.com/p/mytracks/source/browse/MyTracks/src/com/google/android/apps/mytracks/util/LocationUtils.java
It's in the method decimate().
JP


On Jun 30, 2:46 pm, Felix Garcia Lainez fgarcialai...@gmail.com
wrote:
 Hello,

 The case is that i want to show a route on a MapView. Something simple
 at first sight, simply i created a class that extends overlay and
 implement draw method. On this method i iterate over an array of
 GeoPoints and using a canvas y connect all points. It works fine more
 or less, but i am having issues when drawing long routes with many
 points. The problem is that application is very slow, and sometimes
 MapActivity is closed simply doing a zoom in or zoom out on the map
 with the route drawn...

 My question is how to improve performance on this situation

 Thanks!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: MapView Overlay problem

2010-01-08 Thread TreKing
I'm still a bit confused on what you're doing, but I would suggest:

1 - Subclass ItemizedOverlay instead of Overlay to manage a collection of
similar items at once. It maintains a list OverlayItems that represent each
unique point on the map. In your case these would be the Track points you
have.

2 - In your subclass, implement Parcelable and the write method and
constructor that are required to read from / write to a Parcel. In this case
you would write out  / read back each of your OverlayItem's location.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 5:47 PM, Stefan ebay-dah...@web.de wrote:

 hi,
 thanks for your answer :)

 On Jan 5, 11:30 pm, TreKing treking...@gmail.com wrote:
  OK, well your main problem is that while you implemented the Parcelable
  class, you didn't implement the writeToParcel method or the constructor
 that
  takes a Parcel. That's the key.
 

 in one other class of my app i has implement the parcelable to, but
 there i mustnt implement these methods. i dont know why but it works.
 this other class is my SaveHelper class (its like a singleton - i
 only have one object), where i save my track/route... and i test it: i
 walk around my block and i rotate the handy several times
 (==recreation of my activity..). and after saving my gpx file i see,
 that ALL points are saved.

  You need to implement the first method to save all you state information
  (i.e., your member variables) to the Parcel object.
  Then implement the constructor to restore your instance state from the
  incoming Parcel object.

 I override my Overlay object, how you can see in my code and because
 of that i would only get the last overlay back?!?!
 I think you mean, that i do following:

  @Override
  public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub
  dest.writeInt( (int)gp1.getLatitude()); //something like
 that
 }

 and

 private TrackOverlay(Parcel in) {
 gp1.setLatitude(in.readInt());
 }

 but the onSaveInstanceState will only be called, if i pause the
 activity?! So i can only save the last to (TrackOverlay) object?!?!
 Or if i implement these methods i save all my Overlays?!?

 
  Then in your MapActivity onSavedInstanceState, iterate through all of
 your
  Overlays and shove them into an array you can store in the Bundle.
  In onRestoreInstanceState, get a list of Parcelables from the Bundle and
  re-create all of your Overlays (using the constructor that takes a
 Parcel).

 Perhaps it is easier to save all GeoPoints in a list and in
 onSaveInstanceState() i iterate through that list and save all
 GeoPoints in a int [] lat and int [] lon array and put it to my
 bundle and in onRestoreInstanceState i read this arrays and iterate
 through these arrays  and draw the Overlays again, like:

 gp1.setLatitude(lat[0]); .
 for(int i= 1; i lat.length; i++)
 {
gp2 = gp1;
gp1.setLatitude(..)
 ...
   newOverlay = new TrackOverlay(gp1, gp2, MODUS);
   map.getOverlays().add(newOverlay);
 }
 map.ivalidate();



 But what is more efficient and/or more elegant ?

 
  Other bit of advise: get rid of that if (first) { /*initialze*/} code.
 Set
  up your MyLocationOverlay object in onCreate. If you need to have a
 starting
  location while you wait for the first update, use getLastKnownLocation().
 

 Yes, this is not the best solution and i will optimize it soon :)

  I hope that makes sense and helps some.

 Thanks for your detailed answer.

 Stefan

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2010-01-06 Thread Stefan
On Jan 6, 4:57 am, Peter SSK sasikumar.it1...@gmail.com wrote:
 see this link

 http://www.androidpeople.com/category/google-map/


is that the right link? There i only see, how to display a Map. Thats
not the problem. But perhaps i dont find the right part?!
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2010-01-05 Thread Master_Ne0
I also had this problem, i had to save the overlay locations to the
outstate bundle then add them again onResume. Couldn't figure a way to
save my overlay class to bundle. Let me know if you find a better
workaround.

Ne0

On Jan 5, 11:59 am, Stefan ebay-dah...@web.de wrote:
 hello,

 i have an activity with a MapView ad overlays. If i start a new
 activity and go back to my Activity with the map, i only see the map
 without my overlays. How can i save my overlays?? The
 mapView.onSaveInstanceState() does not save the overlays, does it? Or
 have i implement something wrong and the overlays should be visible
 after i come back to my MapActivity?

 Thanks in advance.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: MapView Overlay problem

2010-01-05 Thread Stefan
On Jan 5, 1:16 pm, Master_Ne0 master.ne0s.soluti...@googlemail.com
wrote:
 I also had this problem, i had to save the overlay locations to the
 outstate bundle then add them again onResume. Couldn't figure a way to
 save my overlay class to bundle. Let me know if you find a better
 workaround.

 Ne0


Thanks for your fast answer. Because this is the best idea until know,
i will test your solution and if i find a better way, i will let you
know.

Thanks again,
Stefan

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: MapView Overlay problem

2010-01-05 Thread TreKing

 Couldn't figure a way to save my overlay class to bundle


Have your Overlay class implement the Parceable interface, which you can
then save to / restore from a Bundle.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 6:48 AM, Stefan ebay-dah...@web.de wrote:

 On Jan 5, 1:16 pm, Master_Ne0 master.ne0s.soluti...@googlemail.com
 wrote:
  I also had this problem, i had to save the overlay locations to the
  outstate bundle then add them again onResume. Couldn't figure a way to
  save my overlay class to bundle. Let me know if you find a better
  workaround.
 
  Ne0
 

 Thanks for your fast answer. Because this is the best idea until know,
 i will test your solution and if i find a better way, i will let you
 know.

 Thanks again,
 Stefan

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2010-01-05 Thread Stefan
On Jan 5, 6:48 pm, TreKing treking...@gmail.com wrote:
  Couldn't figure a way to save my overlay class to bundle

 Have your Overlay class implement the Parceable interface, which you can
 then save to / restore from a Bundle.


hmmm, in my case i have always a new overlay for each line on my map:
in every iteration/run of the onLocationChanged method i call
overlay = new MyOverlay()
before i know the MyLocationOverlay i draw my current location with
the drawOval and for this overlay-object (my_pos = new MyOverlay
(...) ) i use the parcelable.
But i dont know how i can save my other normal overlays, because in
each iteration/run i override my overlay object?
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2010-01-05 Thread TreKing
I'm sorry, but I'm not really following or understanding what you're doing.
Could you clarify or post some sample code?

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 2:35 PM, Stefan ebay-dah...@web.de wrote:

 On Jan 5, 6:48 pm, TreKing treking...@gmail.com wrote:
   Couldn't figure a way to save my overlay class to bundle
 
  Have your Overlay class implement the Parceable interface, which you can
  then save to / restore from a Bundle.
 

 hmmm, in my case i have always a new overlay for each line on my map:
 in every iteration/run of the onLocationChanged method i call
 overlay = new MyOverlay()
 before i know the MyLocationOverlay i draw my current location with
 the drawOval and for this overlay-object (my_pos = new MyOverlay
 (...) ) i use the parcelable.
 But i dont know how i can save my other normal overlays, because in
 each iteration/run i override my overlay object?

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2010-01-05 Thread Stefan
Ok, i try it :)

1. I track gps points in my app and draw my route on a MapView:

@Override
public void onLocationChanged(Location loc)
{
if (loc != null)
{
latitude = loc.getLatitude();
longitude = loc.getLongitude();

if(first)
{
p1 = new GeoPoint((int) (loc.getLatitude()*1E6), (int)
(loc.getLongitude()*1E6));
mc.animateTo(p1);
mc.setZoom(18);
first=false;

//act_pos = new TrackOverlay(p1, p1,1);  I NOW USE
MYLOCATIONOVERLAY
//map.getOverlays().add(act_pos);

mlo = new MyLocationOverlay(TRACKing.this, map);
map.getOverlays().add(mlo);
mlo.enableMyLocation();
mlo.runOnFirstFix(new Runnable() {
public void run() {
mc.animateTo(mlo.getMyLocation());
}  });
}
else
{
p2 = p1;
p1 = new GeoPoint((int) (loc.getLatitude()*1E6), (int)
(loc.getLongitude()*1E6));

to = new TrackOverlay(p1, p2, 0);

//act_pos.setGeoPoints(p1, p2);   I NOW USE 
MYLOCATIONOVERLAY
map.getOverlays().add(to);
mc.animateTo(p1);
map.invalidate();
}
}
}

2. My TrackOverlay class:

public class TrackOverlay extends Overlay implements Parcelable
{
private static final int TRACK = 0;
private GeoPoint gp1, gp2;
private int mode;

public TrackOverlay(GeoPoint gp1,GeoPoint gp2, int mode)
{
this.gp1 = gp1;
this.gp2 = gp2;
this.mode = mode;
}

public void setGeoPoints (GeoPoint gp1, GeoPoint gp2)
{
this.gp1 = gp1;
this.gp2 = gp2;
}

@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
long when)
{
Projection projection = mapView.getProjection();
if (shadow == false)
{
Paint paint = new Paint();
paint.setAntiAlias(true);
Point point = new Point();
if(gp1!=null  gp2 != null)
{
projection.toPixels(gp1, point);

if(mode==TRACK)
{
paint.setColor(Color.BLUE);
Point point2 = new Point();
projection.toPixels(gp2, point2);
paint.setStrokeWidth(5);
paint.setAlpha(120);
canvas.drawLine(point.x, point.y, 
point2.x,point2.y, paint);
}
else
  //atm nothing to do
}
}
return super.draw(canvas, mapView, shadow, when);
}

@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}


@Override
public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub

}

private TrackOverlay (Parcel in)
{

}

public static final Parcelable.CreatorTrackOverlay CREATOR =
new Parcelable.CreatorTrackOverlay()
{
public TrackOverlay createFromParcel(Parcel in)
{
return new TrackOverlay(in);
}
public TrackOverlay[] newArray(int size)
{
return new TrackOverlay[size];
}
};
}

3. If i want to describe a specific point, i start a new activity (via
menue). and if i come back to this activity, i cant see the overlays
any more. So how can I save my overlays??

Thanks,
Stefan

PS: I hope this help you...
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: MapView Overlay problem

2010-01-05 Thread TreKing
OK, well your main problem is that while you implemented the Parcelable
class, you didn't implement the writeToParcel method or the constructor that
takes a Parcel. That's the key.

You need to implement the first method to save all you state information
(i.e., your member variables) to the Parcel object.
Then implement the constructor to restore your instance state from the
incoming Parcel object.

Then in your MapActivity onSavedInstanceState, iterate through all of your
Overlays and shove them into an array you can store in the Bundle.
In onRestoreInstanceState, get a list of Parcelables from the Bundle and
re-create all of your Overlays (using the constructor that takes a Parcel).

Other bit of advise: get rid of that if (first) { /*initialze*/} code. Set
up your MyLocationOverlay object in onCreate. If you need to have a starting
location while you wait for the first update, use getLastKnownLocation().

I hope that makes sense and helps some.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 3:32 PM, Stefan ebay-dah...@web.de wrote:

 Ok, i try it :)

 1. I track gps points in my app and draw my route on a MapView:

 @Override
 public void onLocationChanged(Location loc)
 {
if (loc != null)
{
latitude = loc.getLatitude();
longitude = loc.getLongitude();

if(first)
{
p1 = new GeoPoint((int) (loc.getLatitude()*1E6),
 (int)
 (loc.getLongitude()*1E6));
mc.animateTo(p1);
mc.setZoom(18);
first=false;

//act_pos = new TrackOverlay(p1, p1,1);  I NOW USE
 MYLOCATIONOVERLAY
//map.getOverlays().add(act_pos);

mlo = new MyLocationOverlay(TRACKing.this, map);
map.getOverlays().add(mlo);
mlo.enableMyLocation();
mlo.runOnFirstFix(new Runnable() {
public void run() {
mc.animateTo(mlo.getMyLocation());
}  });
}
else
{
p2 = p1;
p1 = new GeoPoint((int) (loc.getLatitude()*1E6),
 (int)
 (loc.getLongitude()*1E6));

to = new TrackOverlay(p1, p2, 0);

//act_pos.setGeoPoints(p1, p2);   I NOW USE
 MYLOCATIONOVERLAY
map.getOverlays().add(to);
mc.animateTo(p1);
map.invalidate();
}
}
 }

 2. My TrackOverlay class:

 public class TrackOverlay extends Overlay implements Parcelable
 {
private static final int TRACK = 0;
private GeoPoint gp1, gp2;
private int mode;

public TrackOverlay(GeoPoint gp1,GeoPoint gp2, int mode)
{
this.gp1 = gp1;
this.gp2 = gp2;
this.mode = mode;
}

public void setGeoPoints (GeoPoint gp1, GeoPoint gp2)
{
this.gp1 = gp1;
this.gp2 = gp2;
}

@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
 long when)
{
Projection projection = mapView.getProjection();
if (shadow == false)
{
Paint paint = new Paint();
paint.setAntiAlias(true);
Point point = new Point();
if(gp1!=null  gp2 != null)
{
projection.toPixels(gp1, point);

if(mode==TRACK)
{
paint.setColor(Color.BLUE);
Point point2 = new Point();
projection.toPixels(gp2, point2);
paint.setStrokeWidth(5);
paint.setAlpha(120);
canvas.drawLine(point.x, point.y,
 point2.x,point2.y, paint);
}
else
  //atm nothing to do
}
}
return super.draw(canvas, mapView, shadow, when);
}

@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}


@Override
public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub

}

private TrackOverlay (Parcel in)
 

[android-developers] Re: MapView Overlay problem

2010-01-05 Thread Stefan
hi,
thanks for your answer :)

On Jan 5, 11:30 pm, TreKing treking...@gmail.com wrote:
 OK, well your main problem is that while you implemented the Parcelable
 class, you didn't implement the writeToParcel method or the constructor that
 takes a Parcel. That's the key.


in one other class of my app i has implement the parcelable to, but
there i mustnt implement these methods. i dont know why but it works.
this other class is my SaveHelper class (its like a singleton - i
only have one object), where i save my track/route... and i test it: i
walk around my block and i rotate the handy several times
(==recreation of my activity..). and after saving my gpx file i see,
that ALL points are saved.

 You need to implement the first method to save all you state information
 (i.e., your member variables) to the Parcel object.
 Then implement the constructor to restore your instance state from the
 incoming Parcel object.

I override my Overlay object, how you can see in my code and because
of that i would only get the last overlay back?!?!
I think you mean, that i do following:

 @Override
 public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub
 dest.writeInt( (int)gp1.getLatitude()); //something like
that
}

and

private TrackOverlay(Parcel in) {
 gp1.setLatitude(in.readInt());
 }

but the onSaveInstanceState will only be called, if i pause the
activity?! So i can only save the last to (TrackOverlay) object?!?!
Or if i implement these methods i save all my Overlays?!?


 Then in your MapActivity onSavedInstanceState, iterate through all of your
 Overlays and shove them into an array you can store in the Bundle.
 In onRestoreInstanceState, get a list of Parcelables from the Bundle and
 re-create all of your Overlays (using the constructor that takes a Parcel).

Perhaps it is easier to save all GeoPoints in a list and in
onSaveInstanceState() i iterate through that list and save all
GeoPoints in a int [] lat and int [] lon array and put it to my
bundle and in onRestoreInstanceState i read this arrays and iterate
through these arrays  and draw the Overlays again, like:

gp1.setLatitude(lat[0]); .
for(int i= 1; i lat.length; i++)
{
gp2 = gp1;
gp1.setLatitude(..)
...
   newOverlay = new TrackOverlay(gp1, gp2, MODUS);
   map.getOverlays().add(newOverlay);
}
map.ivalidate();



But what is more efficient and/or more elegant ?


 Other bit of advise: get rid of that if (first) { /*initialze*/} code. Set
 up your MyLocationOverlay object in onCreate. If you need to have a starting
 location while you wait for the first update, use getLastKnownLocation().


Yes, this is not the best solution and i will optimize it soon :)

 I hope that makes sense and helps some.

Thanks for your detailed answer.

Stefan
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: MapView Overlay problem

2010-01-05 Thread Peter SSK

see this link

http://www.androidpeople.com/category/google-map/


On Jan 5, 4:59 pm, Stefan ebay-dah...@web.de wrote:
 hello,

 i have an activity with a MapView ad overlays. If i start a new
 activity and go back to my Activity with the map, i only see the map
 without my overlays. How can i save my overlays?? The
 mapView.onSaveInstanceState() does not save the overlays, does it? Or
 have i implement something wrong and the overlays should be visible
 after i come back to my MapActivity?

 Thanks in advance.
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en