Coder Social home page Coder Social logo

Comments (1)

rdoeffinger avatar rdoeffinger commented on July 18, 2024

No way to attach patches? So here it is a plain text...

From 311e9c48e31629bca0d88e1f628ac0f0f63a12bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= <[email protected]>
Date: Sun, 15 Sep 2013 22:12:38 +0200
Subject: [PATCH] Make geo: URI parsing more resilient.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In particular accept URIs with altitude and parameters like
geo:52,0,123;u=5?something
While e.g. Google maps seems to fail with those, apps like
QR droid accept them.

Signed-off-by: Reimar Döffinger <[email protected]>
---
 .../src/net/osmand/plus/activities/search/GeoIntentActivity.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java
index dcadb2b..3e7e116 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java
@@ -232,9 +232,13 @@ public class GeoIntentActivity extends OsmandListActivity {
                                showErrorMessage("");
                        } else {
                                int latIndex = geo.indexOf(',');
-                               int lonIndex = geo.indexOf('?');
-                               lonIndex = lonIndex > 0 ? lonIndex : geo.length();
                                if (latIndex > 0) {
+                                       int lonIndex = geo.indexOf(',', latIndex + 1);
+                                       int altIndex = geo.indexOf(';', latIndex + 1);
+                                       int paramIndex = geo.indexOf('?', latIndex + 1);
+                                       paramIndex = paramIndex > 0 ? paramIndex : geo.length();
+                                       altIndex = altIndex > 0 && altIndex < paramIndex ? altIndex : paramIndex;
+                                       lonIndex = lonIndex > 0 && lonIndex < altIndex ? lonIndex : altIndex;
                                        try {
                                                double lat = Double.parseDouble(geo.substring(0, latIndex).trim());
                                                double lon = Double.parseDouble(geo.substring(latIndex + 1, lonIndex).trim());
-- 
1.8.4.rc3

from osmand.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.