Adding a distance to a GeoPoint

by Eric Crump » Thu, 28 Jan 2010 08:57:52 GMT


Sponsored Links
 I need to draw a circle on my map.  I have the GeoPoint and I have the
radius of the circle in meters.  How do I add a distance to a GeoPoint
and get a GeoPoint as a result?

--



Adding a distance to a GeoPoint

by Kevin Duffey » Thu, 28 Jan 2010 09:18:46 GMT


 I am interested in this too. The numbers are fractional, so I am wondering
how you actually figure out the distance say, a 1/2 inch is on the screen
relative to the zoom level. Is there an api call that takes into account the
zoom level and can give a way to draw a specific distance.. such as a foot,
mile, etc?





>


Sponsored Links


Adding a distance to a GeoPoint

by Eric Crump » Thu, 28 Jan 2010 11:46:54 GMT


 Got it to work with this:

radius = (int)projection.metersToEquatorPixels(item.getRadiusInMeters
());

Still have some rounding issues to work out though

--



Other Threads

1. Programmatically expanding / collapsing items of an ExpandableListView

Simply remember the last expanded group and collapse it before you
expand another group. This way you don't need a loop.
Try this:

private int currentHourPosition = -1; // initial value

            @Override
            public void onGroupExpand(int groupPosition) {
                super.onGroupExpand(groupPosition);
                if(currentHourPosition != -1 && currentHourPosition !=
groupPosition){
                        expandableListView.collapseGroup(currentHourPosition);
                }
                currentHourPosition = groupPosition;
//              expandableListView.setSelectedGroup(groupPosition);
                }


On 6 Aug., 23:08, Fabrizio Giudici <fabrizio.giud...@tidalwave.it>







-- 

2. Submit a Picture to server

Hi everyone...
I wouldn't post about this again if I really wasn't frustrated about
it.. I've been going through this for a whole week and still I'm not
able to do an image upload... My code doesn't report any errors.. but
not even the intent is working.. please take a minute to go through
it.. it's kinda simple.. like I want it to be..

This is my addPic.class on which I have a ImageView, EditText, a
Button to browse the device and a button to add the picture...

This is the code for the browse button:

deviceBrowse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
        Intent i = new Intent(Intent.ACTION_PICK,
        
android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                                                   startActivityForResult(i, 
ACTIVITY_SELECT_IMAGE);
                        }
                });


which calls :


    protected void onActivityResult(int requestCode, int resultCode,
Intent imageReturnedIntent) {
        super.onActivityResult(requestCode, resultCode,
imageReturnedIntent);

        switch(requestCode) {
        case ACTIVITY_SELECT_IMAGE:
            if(resultCode == RESULT_OK){
                Uri selectedImage = imageReturnedIntent.getData();
                String[] filePathColumn =
{MediaStore.Images.Media.DATA};
                Cursor cursor =
getContentResolver().query(selectedImage, filePathColumn, null, null,
null);
                cursor.moveToFirst();
                int columnIndex =
cursor.getColumnIndex(filePathColumn[0]);
                filePath = cursor.getString(columnIndex);
                cursor.close();
                selectedDeviceImage =
BitmapFactory.decodeFile(filePath);
                                picPreview.setImageBitmap(selectedDeviceImage);
                                label.setText(filePath);
                                exsistingFileName = filePath;
            }
        }
    }

This last piece of code ..put's the path of the file in the label and
the bitmap on the Imageview so I can have a preview..


So here is my problematic piece of code: the add button

 add.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                              doFileUpload();
                                        // Go to camera mode
                                        Intent addIntent = new 
Intent(v.getContext(), editPic.class);
                                Bundle w = new Bundle();
                                String activityName = "addPic";
                                w.putString("activity", activityName);
                                w.putParcelable("bitmap", selectedDeviceImage);
                                //a.putString("id", picId);
                                addIntent.putExtras(w);
                                startActivity(addIntent);
                                finish();

I'll show you the doFileUpload() in a minute... I just wanted to
mention that the intent is not working God knows why.. it doesn't go
to the class I specified...

 private void doFileUpload(){

        HttpURLConnection conn = null;
        DataOutputStream dos = null;
        DataInputStream inStream = null;
        exsistingFileName = filePath;

        // Is this the place are you doing something wrong.

        String lineEnd = "rn";
        String twoHyphens = "--";
        String boundary =  "*****";


        int bytesRead, bytesAvailable, bufferSize;
        byte[] buffer;
        int maxBufferSize = 1*1024*1024;
        String responseFromServer = "";
        String urlString = "http://www.pedroteixeira.org/thennnow/
UT9.php";
        try
        {
        Log.e("MediaPlayer","Inside second Method");
        FileInputStream fileInputStream = new FileInputStream(new
File(exsistingFileName) );
         // open a URL connection to the Servlet
         URL url = new URL(urlString);
         // Open a HTTP connection to the URL
         conn = (HttpURLConnection) url.openConnection();
         // Allow Inputs
         conn.setDoInput(true);
         // Allow Outputs
         conn.setDoOutput(true);
         // Don't use a cached copy.
         conn.setUseCaches(false);
         // Use a post method.
         conn.setRequestMethod("POST");
         conn.setRequestProperty("Connection", "Keep-Alive");
         conn.setRequestProperty("Content-Type", "multipart/form-
data;boundary="+boundary);
         dos = new DataOutputStream( conn.getOutputStream() );
         dos.writeBytes(twoHyphens + boundary + lineEnd);
         dos.writeBytes("Content-Disposition: form-data; name=
\"uploadedfile\";filename=\"" + exsistingFileName +"\"" +
lineEnd);
         dos.writeBytes(lineEnd);
         Log.e("MediaPlayer","Headers are written");
         // create a buffer of maximum size
         bytesAvailable = fileInputStream.available();
         bufferSize = Math.min(bytesAvailable, maxBufferSize);
         buffer = new byte[bufferSize];
         // read file and write it into form...
         bytesRead = fileInputStream.read(buffer, 0, bufferSize);
         while (bytesRead > 0)
         {
          dos.write(buffer, 0, bufferSize);
          bytesAvailable = fileInputStream.available();
          bufferSize = Math.min(bytesAvailable, maxBufferSize);
          bytesRead = fileInputStream.read(buffer, 0, bufferSize);
         }
         // send multipart form data necesssary after file data...
         dos.writeBytes(lineEnd);
         dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
         // close streams
         Log.e("MediaPlayer","File is written");
         fileInputStream.close();
         dos.flush();
         dos.close();
        }
        catch (MalformedURLException ex)
        {
             Log.e("MediaPlayer", "error: " + ex.getMessage(), ex);
        }
        catch (IOException ioe)
        {
             Log.e("MediaPlayer", "error: " + ioe.getMessage(), ioe);
        }
        //------------------ read the SERVER RESPONSE
        try {
              inStream = new DataInputStream
( conn.getInputStream() );
              String str;
              while (( str = inStream.readLine()) != null)
              {
                   Log.e("MediaPlayer","Server Response"+str);
              }
              inStream.close();
        }
        catch (IOException ioex){
             Log.e("MediaPlayer", "error: " + ioex.getMessage(),
ioex);
        }

      }



On the server side.. the php is working since I've tested it with HTML
form.. it's just this piece of code which doesnt work .. I have no
ideia.. can someone please help me? :(

-- 

3. Cannot use the sdcard while connected by means of USB - problems testing

4. one problem regarding sdk addon

5. Android wifi power mode - kernel or API?

6. GUI alignment ok for emulator and direct transfer but misaligned when published in Android Market?

7. Why has my app disappeared from the market? Has this happened to anyone before?