From 89d0f9cebd9e20f99e7fd84c89c5c98539c2bc6a Mon Sep 17 00:00:00 2001 From: xmaniac Date: Fri, 15 May 2009 16:37:22 +0200 Subject: [PATCH] Ported the command API --- blackberry/.classpath | 2 +- blackberry/.project | 12 +- .../.settings/net.rim.eide.keys.Project.prefs | 3 + .../.settings/org.eclipse.jdt.core.prefs | 4 +- blackberry/phonegap.cso | 5 + blackberry/phonegap.jdp | 56 +++++++ .../src/com/nitobi/phonegap/api/Command.java | 50 ++++++ .../phonegap/api/impl/GeoLocationCommand.java | 150 ++++++++++++++++++ .../api/impl/InitializationCommand.java | 72 +++++++++ .../phonegap/api/impl/TelephonyCommand.java | 65 ++++++++ .../phonegap/api/impl/VibrationCommand.java | 64 ++++++++ .../com/nitobi/phonegap/model/Position.java | 83 ++++++++++ 12 files changed, 560 insertions(+), 6 deletions(-) create mode 100644 blackberry/.settings/net.rim.eide.keys.Project.prefs create mode 100644 blackberry/phonegap.cso create mode 100644 blackberry/phonegap.jdp create mode 100644 blackberry/src/com/nitobi/phonegap/api/Command.java create mode 100644 blackberry/src/com/nitobi/phonegap/api/impl/GeoLocationCommand.java create mode 100644 blackberry/src/com/nitobi/phonegap/api/impl/InitializationCommand.java create mode 100644 blackberry/src/com/nitobi/phonegap/api/impl/TelephonyCommand.java create mode 100644 blackberry/src/com/nitobi/phonegap/api/impl/VibrationCommand.java create mode 100644 blackberry/src/com/nitobi/phonegap/model/Position.java diff --git a/blackberry/.classpath b/blackberry/.classpath index da072afc..6c335059 100644 --- a/blackberry/.classpath +++ b/blackberry/.classpath @@ -1,7 +1,7 @@ - + diff --git a/blackberry/.project b/blackberry/.project index f185ab1f..78f3da0c 100644 --- a/blackberry/.project +++ b/blackberry/.project @@ -1,6 +1,6 @@ - phone_gap + phonegap @@ -11,7 +11,12 @@ - net.rim.eide.RIMIncrementalProjectBuilder + net.rim.eide.PreprocessBuilder + + + + + net.rim.eide.JavaIncrementalProjectBuilder @@ -19,5 +24,6 @@ net.rim.eide.rimnature org.eclipse.jdt.core.javanature + net.rim.eide.PreprocessingNature - + \ No newline at end of file diff --git a/blackberry/.settings/net.rim.eide.keys.Project.prefs b/blackberry/.settings/net.rim.eide.keys.Project.prefs new file mode 100644 index 00000000..0a031f6b --- /dev/null +++ b/blackberry/.settings/net.rim.eide.keys.Project.prefs @@ -0,0 +1,3 @@ +#Fri May 15 15:56:25 CEST 2009 +RIM.BLACKBERRY.TYPE=COPY +eclipse.preferences.version=1 diff --git a/blackberry/.settings/org.eclipse.jdt.core.prefs b/blackberry/.settings/org.eclipse.jdt.core.prefs index f8fbd94d..fafbe46c 100644 --- a/blackberry/.settings/org.eclipse.jdt.core.prefs +++ b/blackberry/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,5 @@ -#Sun Oct 19 18:43:38 PDT 2008 +#Fri May 15 15:56:25 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.compliance=1.3 +org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.source=1.3 diff --git a/blackberry/phonegap.cso b/blackberry/phonegap.cso new file mode 100644 index 00000000..fe1ac700 --- /dev/null +++ b/blackberry/phonegap.cso @@ -0,0 +1,5 @@ +33000000=RIMAPPSA2 +52424200=RIM Blackberry Apps API +52434300=RIM Crypto API - Certicom +52434900=RIM Crypto API - Internal +52435200=RIM Crypto API - RIM diff --git a/blackberry/phonegap.jdp b/blackberry/phonegap.jdp new file mode 100644 index 00000000..dd87a0cb --- /dev/null +++ b/blackberry/phonegap.jdp @@ -0,0 +1,56 @@ +## RIM Java Development Environment +# RIM Project file +# +# This file is generated and managed by BlackBerry developer tools. +# It SHOULD NOT BE modified manually. +# +AddOn=0 +AlwaysBuild=0 +[AlxImports +] +AutoRestart=0 +[ClassProtection +] +[CustomBuildFiles +] +[CustomBuildRules +] +[DefFiles +] +[DependsOn +] +ExcludeFromBuildAll=0 +[Files +src\com\nitobi\phonegap\api\Command.java +src\com\nitobi\phonegap\api\impl\GeoLocationCommand.java +src\com\nitobi\phonegap\api\impl\InitializationCommand.java +src\com\nitobi\phonegap\api\impl\TelephonyCommand.java +src\com\nitobi\phonegap\api\impl\VibrationCommand.java +src\com\nitobi\phonegap\model\Position.java +src\com\nitobi\phonegap\PhoneGap.java +src\com\nitobi\phonegap\SecondaryResourceFetchThread.java +src\com\nitobi\phonegap\Utilities.java +] +HaveAlxImports=0 +HaveDefs=0 +HaveImports=0 +[Icons +] +[ImplicitRules +] +[Imports +] +Listing=0 +Options=-quiet +OutputFileName=phonegap +[PackageProtection +] +RibbonPosition=0 +[RolloverIcons +] +RunOnStartup=0 +StartupTier=7 +SystemModule=0 +Title=PhoneGap +Type=0 +UserData=|src diff --git a/blackberry/src/com/nitobi/phonegap/api/Command.java b/blackberry/src/com/nitobi/phonegap/api/Command.java new file mode 100644 index 00000000..20a871ea --- /dev/null +++ b/blackberry/src/com/nitobi/phonegap/api/Command.java @@ -0,0 +1,50 @@ +/** + * The MIT License + * ------------------------------------------------------------- + * Copyright (c) 2008, Rob Ellis, Brock Whitten, Brian Leroux, Joe Bowser, Dave Johnson, Nitobi + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.nitobi.phonegap.api; + +/** + * Each part of the PhoneGap API. + * + * @author Jose Noheda [jose.noheda@gmail.com] + * + */ +public interface Command { + + /** + * Executes the request and returns JS code to chang client state. + * + * @param instruction the command to execute + * @return a string with Javascript code or null + */ + String execute(String instruction); + + /** + * Determines if this command can process a request. + * + * @param instruction the command to execute + * + * @return true if this command understands the petition + */ + boolean accept(String instruction); + +} diff --git a/blackberry/src/com/nitobi/phonegap/api/impl/GeoLocationCommand.java b/blackberry/src/com/nitobi/phonegap/api/impl/GeoLocationCommand.java new file mode 100644 index 00000000..9408bfae --- /dev/null +++ b/blackberry/src/com/nitobi/phonegap/api/impl/GeoLocationCommand.java @@ -0,0 +1,150 @@ +/** + * The MIT License + * ------------------------------------------------------------- + * Copyright (c) 2008, Rob Ellis, Brock Whitten, Brian Leroux, Joe Bowser, Dave Johnson, Nitobi + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.nitobi.phonegap.api.impl; + +import javax.microedition.location.Location; +import javax.microedition.location.LocationException; +import javax.microedition.location.LocationListener; +import javax.microedition.location.LocationProvider; + +import net.rim.blackberry.api.invoke.Invoke; +import net.rim.blackberry.api.invoke.MapsArguments; + +import com.nitobi.phonegap.api.Command; +import com.nitobi.phonegap.model.Position; + +/** + * Wraps all GPS functions. + * + * @author Jose Noheda + * + */ +public class GeoLocationCommand implements Command { + + private static final int MAP_COMMAND = 0; + private static final int STOP_COMMAND = 1; + private static final int START_COMMAND = 2; + private static final int CHECK_COMMAND = 3; + private static final int CAPTURE_INTERVAL = 5; + private static final String CODE = "gap://location"; + + private Position position; + private boolean availableGPS = true; + private LocationProvider locationProvider; + + public GeoLocationCommand() { + try { + locationProvider = LocationProvider.getInstance(null); + } catch (LocationException e) { + availableGPS = false; + } + } + + /** + * Able to run the location command (all options). + * Ex: gap://location/start + */ + public boolean accept(String instruction) { + return instruction != null && instruction.startsWith(CODE); + } + + /** + * Deletes the last valid obtained position. + */ + public void clearPosition() { + position = null; + } + + /** + * Executes the following sub-commands: + * START: Initiliazes the internal GPS module + * STOP: Stops GPS module (saving battery life) + * CHECK: Reads latest position available + * MAP: Invokes the internal MAP application + */ + public String execute(String instruction) { + if (!availableGPS) return ";alert('GPS not available');"; + switch (getCommand(instruction)) { + case MAP_COMMAND: if (position != null) Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT, getLocationDocument())); + break; + case STOP_COMMAND: clearPosition(); + locationProvider.setLocationListener(null, 0, 0, 0); + return ";navigator.geolocation.started = false;"; + case START_COMMAND: locationProvider.setLocationListener(new LocationListenerImpl(this), CAPTURE_INTERVAL, 1, 1); + return ";navigator.geolocation.started = true;"; + case CHECK_COMMAND: if (position != null) return ";navigator.geolocation.lastPosition = " + position.toJavascript() + ";"; + } + return null; + } + + private int getCommand(String instruction) { + String command = instruction.substring(instruction.lastIndexOf('/') + 1); + if ("map".equals(command)) return MAP_COMMAND; + if ("start".equals(command)) return START_COMMAND; + if ("check".equals(command)) return CHECK_COMMAND; + return -1; + } + + private void updateLocation(double lat, double lng, float speed, float heading, float altitude) { + position = new Position(); + position.setLatitude(lat); + position.setLongitude(lng); + position.setVelocity(speed); + position.setHeading(heading); + position.setAltitude(altitude); + } + + private String getLocationDocument() { + StringBuffer location = new StringBuffer(""); + return location.toString(); + } + + /** + * Implementation of the LocationListener interface + */ + private class LocationListenerImpl implements LocationListener { + + private GeoLocationCommand command; + + public LocationListenerImpl(GeoLocationCommand command) { + this.command = command; + } + + public void locationUpdated(LocationProvider provider, Location location) { + if (location.isValid()) { + float heading = location.getCourse(); + double longitude = location.getQualifiedCoordinates().getLongitude(); + double latitude = location.getQualifiedCoordinates().getLatitude(); + float altitude = location.getQualifiedCoordinates().getAltitude(); + float speed = location.getSpeed(); + command.updateLocation(latitude, longitude, speed, heading, altitude); + } else command.clearPosition(); + } + + public void providerStateChanged(LocationProvider provider, int newState) {} + } + +} diff --git a/blackberry/src/com/nitobi/phonegap/api/impl/InitializationCommand.java b/blackberry/src/com/nitobi/phonegap/api/impl/InitializationCommand.java new file mode 100644 index 00000000..9f81f4d3 --- /dev/null +++ b/blackberry/src/com/nitobi/phonegap/api/impl/InitializationCommand.java @@ -0,0 +1,72 @@ +/** + * The MIT License + * ------------------------------------------------------------- + * Copyright (c) 2008, Rob Ellis, Brock Whitten, Brian Leroux, Joe Bowser, Dave Johnson, Nitobi + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.nitobi.phonegap.api.impl; + +import com.nitobi.phonegap.api.Command; +import net.rim.device.api.system.DeviceInfo; + +/** + * Configures the Device API. + * + * @author Jose Noheda [jose.noheda@gmail.com] + * + */ +public class InitializationCommand implements Command { + + private static final String CODE = "gap://initialize"; + + /** + * Able to run the initialize command (usually onLoad). + */ + public boolean accept(String instruction) { + return instruction != null && instruction.startsWith(CODE); + } + + /** + * Fills the JS variable Device with: + * Model + * Flash memory available + * Platform + * Vendor + * Battery + * Software version + * Camera support + * ID + * Simulator + * + */ + public String execute(String instruction) { + StringBuffer deviceInfo = new StringBuffer(";Device.model = '"); + deviceInfo.append(DeviceInfo.getDeviceName()).append("';Device.flash = "); + deviceInfo.append(DeviceInfo.getTotalFlashSize()).append(";Device.platform = '"); + deviceInfo.append(DeviceInfo.getPlatformVersion()).append("';Device.vendor = '"); + deviceInfo.append(DeviceInfo.getManufacturerName()).append("';Device.battery = "); + deviceInfo.append(DeviceInfo.getBatteryLevel()).append(";Device.version = '"); + deviceInfo.append(DeviceInfo.getSoftwareVersion()).append("';Device.isSimulator = "); + deviceInfo.append(DeviceInfo.isSimulator()).append(";Device.hasCamera = "); + deviceInfo.append(DeviceInfo.hasCamera()).append(";Device.uuid = "); + deviceInfo.append(DeviceInfo.getDeviceId()).append(";"); + return deviceInfo.toString(); + } + +} diff --git a/blackberry/src/com/nitobi/phonegap/api/impl/TelephonyCommand.java b/blackberry/src/com/nitobi/phonegap/api/impl/TelephonyCommand.java new file mode 100644 index 00000000..958f4938 --- /dev/null +++ b/blackberry/src/com/nitobi/phonegap/api/impl/TelephonyCommand.java @@ -0,0 +1,65 @@ +/** + * The MIT License + * ------------------------------------------------------------- + * Copyright (c) 2008, Rob Ellis, Brock Whitten, Brian Leroux, Joe Bowser, Dave Johnson, Nitobi + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.nitobi.phonegap.api.impl; + +import net.rim.blackberry.api.invoke.Invoke; +import net.rim.blackberry.api.invoke.PhoneArguments; + +import com.nitobi.phonegap.api.Command; + +/** + * Makes a telephone call by switching to the internal application. + * + * @author Jose Noheda + * + */ +public class TelephonyCommand implements Command { + + private static final String CODE = "gap://call"; + + /** + * Able to run the call command. Ex: gap://call/555666777 + */ + public boolean accept(String instruction) { + return instruction != null && instruction.startsWith(CODE); + } + + /** + * Invokes internal phone application. + */ + public String execute(String instruction) { + String number = getNumber(instruction); + if (number != null) + Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, new PhoneArguments(PhoneArguments.ARG_CALL, number)); + return null; + } + + private String getNumber(String instruction) { + try { + return instruction.substring(instruction.lastIndexOf('/') + 1); + } catch(Exception ex) { + return null; + } + } + +} diff --git a/blackberry/src/com/nitobi/phonegap/api/impl/VibrationCommand.java b/blackberry/src/com/nitobi/phonegap/api/impl/VibrationCommand.java new file mode 100644 index 00000000..94b24aef --- /dev/null +++ b/blackberry/src/com/nitobi/phonegap/api/impl/VibrationCommand.java @@ -0,0 +1,64 @@ +/** + * The MIT License + * ------------------------------------------------------------- + * Copyright (c) 2008, Rob Ellis, Brock Whitten, Brian Leroux, Joe Bowser, Dave Johnson, Nitobi + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.nitobi.phonegap.api.impl; + +import net.rim.device.api.system.Alert; + +import com.nitobi.phonegap.api.Command; + +/** + * Vibrates the phone if able. + * + * @author Jose Noheda + * + */ +public class VibrationCommand implements Command { + + private static final int DURATION = 5; + private static final String CODE = "gap://vibrate"; + + /** + * Able to run the vibrate command. Ex: gap://vibrate/10 + */ + public boolean accept(String instruction) { + return instruction != null && instruction.startsWith(CODE); + } + + /** + * Checks if the phone has the require vibration module and + * activates it (by default, for 5 seconds). + */ + public String execute(String instruction) { + if (Alert.isVibrateSupported()) Alert.startVibrate(getVibrateDuration(instruction)); + return null; + } + + private int getVibrateDuration(String instruction) { + try { + return Integer.parseInt(instruction.substring(instruction.lastIndexOf('/') + 1)); + } catch(Exception ex) { + return DURATION; + } + } + +} \ No newline at end of file diff --git a/blackberry/src/com/nitobi/phonegap/model/Position.java b/blackberry/src/com/nitobi/phonegap/model/Position.java new file mode 100644 index 00000000..652883b6 --- /dev/null +++ b/blackberry/src/com/nitobi/phonegap/model/Position.java @@ -0,0 +1,83 @@ +/** + * The MIT License + * ------------------------------------------------------------- + * Copyright (c) 2008, Rob Ellis, Brock Whitten, Brian Leroux, Joe Bowser, Dave Johnson, Nitobi + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.nitobi.phonegap.model; + +/** + * Stores geo location variables. + * + * @author Jose Noheda + * + */ +public class Position { + + private double _lat = 0; + private double _lng = 0; + private float heading = 0; + private float altitude = 0; + private float velocity = 0; + + public double getLatitude() { + return _lat; + } + + public void setLatitude(double _lat) { + this._lat = _lat; + } + + public double getLongitude() { + return _lng; + } + + public void setLongitude(double _lng) { + this._lng = _lng; + } + + public float getHeading() { + return heading; + } + + public void setHeading(float heading) { + this.heading = heading; + } + + public float getAltitude() { + return altitude; + } + + public void setAltitude(float altitude) { + this.altitude = altitude; + } + + public float getVelocity() { + return velocity; + } + + public void setVelocity(float velocity) { + this.velocity = velocity; + } + + public String toJavascript() { + return "new Position(" + _lat + "," + _lng + ",1," + altitude + ",1" + heading + "," + velocity + ")"; + } + +}