idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
153,100
public static ITileSource getTileSource ( final int aOrdinal ) throws IllegalArgumentException { for ( final ITileSource tileSource : mTileSources ) { if ( tileSource . ordinal ( ) == aOrdinal ) { return tileSource ; } } throw new IllegalArgumentException ( "No tile source at position: " + aOrdinal ) ; }
Get the tile source at the specified position .
153,101
public static int removeTileSources ( final String aRegex ) { int n = 0 ; for ( int i = mTileSources . size ( ) - 1 ; i >= 0 ; -- i ) { if ( mTileSources . get ( i ) . name ( ) . matches ( aRegex ) ) { mTileSources . remove ( i ) ; ++ n ; } } return n ; }
removes any tile sources whose name matches the regular expression
153,102
private static void startServer ( ) throws Exception { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean ( ) ; sf . setResourceClasses ( TileFetcher . class ) ; List < Object > providers = new ArrayList < Object > ( ) ; providers . add ( new org . apache . cxf . jaxrs . provider . JAXBElementProvider ( ) ) ; provi...
this files up a CXF based Jetty server to host tile rest service
153,103
public void add ( ShapeMarkers shapeMarkers ) { for ( Marker marker : shapeMarkers . getMarkers ( ) ) { add ( marker , shapeMarkers ) ; } }
Add all markers in the shape
153,104
public static void addMarkerAsPolyline ( Marker marker , List < Marker > markers ) { GeoPoint position = marker . getPosition ( ) ; int insertLocation = markers . size ( ) ; if ( markers . size ( ) > 1 ) { double [ ] distances = new double [ markers . size ( ) ] ; insertLocation = 0 ; distances [ 0 ] = SphericalUtil . ...
Polyline add a marker in the list of markers to where it is closest to the the surrounding points
153,105
public void showInfoWindow ( ) { if ( mInfoWindow == null ) return ; final int markerWidth = mIcon . getIntrinsicWidth ( ) ; final int markerHeight = mIcon . getIntrinsicHeight ( ) ; final int offsetX = ( int ) ( markerWidth * ( mIWAnchorU - mAnchorU ) ) ; final int offsetY = ( int ) ( markerHeight * ( mIWAnchorV - mAn...
shows the info window if it s open this will close and reopen it
153,106
public void onDetach ( MapView mapView ) { BitmapPool . getInstance ( ) . asyncRecycle ( mIcon ) ; mIcon = null ; BitmapPool . getInstance ( ) . asyncRecycle ( mImage ) ; this . mOnMarkerClickListener = null ; this . mOnMarkerDragListener = null ; this . mResources = null ; setRelatedObject ( null ) ; if ( isInfoWindow...
Null out the static references when the MapView is detached to prevent memory leaks .
153,107
public static double orthogonalDistance ( GeoPoint point , GeoPoint lineStart , GeoPoint lineEnd ) { double area = Math . abs ( ( lineStart . getLatitude ( ) * lineEnd . getLongitude ( ) + lineEnd . getLatitude ( ) * point . getLongitude ( ) + point . getLatitude ( ) * lineStart . getLongitude ( ) - lineEnd . getLatitu...
Calculate the orthogonal distance from the line joining the lineStart and lineEnd points to point
153,108
public void onClick ( View v ) { switch ( v . getId ( ) ) { case R . id . buttonManualCacheEntry : { showManualEntry ( ) ; } break ; case R . id . buttonSetCache : { showPickCacheFromList ( ) ; } break ; } }
END PERMISSION CHECK
153,109
public void closeAllInfoWindows ( ) { for ( Overlay overlay : mOverlayManager ) { if ( overlay instanceof FolderOverlay ) { ( ( FolderOverlay ) overlay ) . closeAllInfoWindows ( ) ; } else if ( overlay instanceof OverlayWithIW ) { ( ( OverlayWithIW ) overlay ) . closeInfoWindow ( ) ; } } }
Close all opened InfoWindows of overlays it contains . This only operates on overlays that inherit from OverlayWithIW .
153,110
private ImageryMetaDataResource getMetaData ( ) { Log . d ( IMapView . LOGTAG , "getMetaData" ) ; ImageryMetaDataResource returnValue = null ; InputStream in = null ; HttpURLConnection client = null ; ByteArrayOutputStream dataStream = null ; BufferedOutputStream out = null ; try { client = ( HttpURLConnection ) ( new ...
Gets the imagery meta from the REST service or null if it fails
153,111
public boolean shouldIgnore ( final String pProvider , final long pTime ) { if ( LocationManager . GPS_PROVIDER . equals ( pProvider ) ) { mLastGps = pTime ; } else { if ( pTime < mLastGps + Configuration . getInstance ( ) . getGpsWaitTime ( ) ) { return true ; } } return false ; }
Whether we should ignore this location .
153,112
private double adjustScaleBarLength ( double length ) { long pow = 0 ; boolean feet = false ; if ( unitsOfMeasure == UnitsOfMeasure . imperial ) { if ( length >= GeoConstants . METERS_PER_STATUTE_MILE / 5 ) length = length / GeoConstants . METERS_PER_STATUTE_MILE ; else { length = length * GeoConstants . FEET_PER_METER...
Returns a reduced length that starts with 1 2 or 5 and trailing zeros . If set to nautical or imperial the input will be transformed before and after the reduction so that the result holds in that respective unit .
153,113
public static Location getLastKnownLocation ( final LocationManager pLocationManager ) { if ( pLocationManager == null ) { return null ; } final Location gpsLocation = getLastKnownLocation ( pLocationManager , LocationManager . GPS_PROVIDER ) ; final Location networkLocation = getLastKnownLocation ( pLocationManager , ...
Get the most recent location from the GPS or Network provider .
153,114
public void setInfoWindow ( InfoWindow infoWindow ) { if ( mInfoWindow != null ) { if ( mInfoWindow . getRelatedObject ( ) == this ) mInfoWindow . setRelatedObject ( null ) ; } mInfoWindow = infoWindow ; }
Set the InfoWindow to be used . Default is a BasicInfoWindow with the layout named bonuspack_bubble . You can use this method either to use your own layout or to use your own sub - class of InfoWindow . If you don t want any InfoWindow to open you can set it to null .
153,115
public List < List < GeoPoint > > getHoles ( ) { List < List < GeoPoint > > result = new ArrayList < List < GeoPoint > > ( mHoles . size ( ) ) ; for ( LinearRing hole : mHoles ) { result . add ( hole . getPoints ( ) ) ; } return result ; }
returns a copy of the holes this polygon contains
153,116
public static ArrayList < GeoPoint > pointsAsCircle ( GeoPoint center , double radiusInMeters ) { ArrayList < GeoPoint > circlePoints = new ArrayList < GeoPoint > ( 360 / 6 ) ; for ( int f = 0 ; f < 360 ; f += 6 ) { GeoPoint onCircle = center . destinationPoint ( radiusInMeters , f ) ; circlePoints . add ( onCircle ) ;...
Build a list of GeoPoint as a circle .
153,117
protected void setDefaultInfoWindowLocation ( ) { int s = mOutline . getPoints ( ) . size ( ) ; if ( s == 0 ) { mInfoWindowLocation = new GeoPoint ( 0.0 , 0.0 ) ; return ; } mInfoWindowLocation = mOutline . getCenter ( null ) ; }
Internal method used to ensure that the infowindow will have a default position in all cases so that the user can call showInfoWindow even if no tap occured before . Currently set the position on the center of the polygon bounding box .
153,118
public Point toPixelsFromProjected ( final PointL in , final Point reuse ) { final Point out = reuse != null ? reuse : new Point ( ) ; final double power = getProjectedPowerDifference ( ) ; final PointL tmp = new PointL ( ) ; getLongPixelsFromProjected ( in , power , true , tmp ) ; out . x = TileSystem . truncateToInt ...
Performs the second computationally light part of the projection .
153,119
public Point unrotateAndScalePoint ( int x , int y , Point reuse ) { return applyMatrixToPoint ( x , y , reuse , mUnrotateAndScaleMatrix , mOrientation != 0 ) ; }
This will revert the current map s scaling and rotation for a point . This can be useful when drawing to a fixed location on the screen .
153,120
public Point rotateAndScalePoint ( int x , int y , Point reuse ) { return applyMatrixToPoint ( x , y , reuse , mRotateAndScaleMatrix , mOrientation != 0 ) ; }
This will apply the current map s scaling and rotation for a point . This can be useful when converting MotionEvents to a screen point .
153,121
public void adjustOffsets ( final IGeoPoint pGeoPoint , final PointF pPixel ) { if ( pPixel == null ) { return ; } final Point unRotatedExpectedPixel = unrotateAndScalePoint ( ( int ) pPixel . x , ( int ) pPixel . y , null ) ; final Point unRotatedActualPixel = toPixels ( pGeoPoint , null ) ; final long deltaX = unRota...
Adjust the offsets so that this geo point projects into that pixel
153,122
public void adjustOffsets ( final BoundingBox pBoundingBox ) { if ( pBoundingBox == null ) { return ; } adjustOffsets ( pBoundingBox . getLonWest ( ) , pBoundingBox . getLonEast ( ) , false , 0 ) ; adjustOffsets ( pBoundingBox . getActualNorth ( ) , pBoundingBox . getActualSouth ( ) , true , 0 ) ; }
Adjust the offsets so that either this bounding box is bigger than the screen and contains it or it is smaller and it is centered
153,123
protected String quadTree ( final long pMapTileIndex ) { final StringBuilder quadKey = new StringBuilder ( ) ; for ( int i = MapTileIndex . getZoom ( pMapTileIndex ) ; i > 0 ; i -- ) { int digit = 0 ; final int mask = 1 << ( i - 1 ) ; if ( ( MapTileIndex . getX ( pMapTileIndex ) & mask ) != 0 ) digit += 1 ; if ( ( MapT...
Converts TMS tile coordinates to QuadTree
153,124
public void mapTileRequestFailed ( final MapTileRequestState pState ) { if ( mTileNotFoundImage != null ) { putTileIntoCache ( pState . getMapTile ( ) , mTileNotFoundImage , ExpirableBitmapDrawable . NOT_FOUND ) ; for ( final Handler handler : mTileRequestCompleteHandlers ) { if ( handler != null ) { handler . sendEmpt...
Called by implementation class methods indicating that they have failed to retrieve the requested map tile . a MAPTILE_FAIL_ID message is sent .
153,125
public void mapTileRequestExpiredTile ( MapTileRequestState pState , Drawable pDrawable ) { putTileIntoCache ( pState . getMapTile ( ) , pDrawable , ExpirableBitmapDrawable . getState ( pDrawable ) ) ; for ( final Handler handler : mTileRequestCompleteHandlers ) { if ( handler != null ) { handler . sendEmptyMessage ( M...
Called by implementation class methods indicating that they have produced an expired result that can be used but better results may be delivered later . The tile is added to the cache and a MAPTILE_SUCCESS_ID message is sent .
153,126
public void rescaleCache ( final Projection pProjection , final double pNewZoomLevel , final double pOldZoomLevel , final Rect pViewPort ) { if ( TileSystem . getInputTileZoomLevel ( pNewZoomLevel ) == TileSystem . getInputTileZoomLevel ( pOldZoomLevel ) ) { return ; } final long startMs = System . currentTimeMillis ( ...
Recreate the cache using scaled versions of the tiles currently in it
153,127
protected boolean onDrawItem ( final Canvas canvas , final Item item , final Point curScreenCoords , final Projection pProjection ) { final int state = ( mDrawFocusedItem && ( mFocusedItem == item ) ? OverlayItem . ITEM_STATE_FOCUSED_MASK : 0 ) ; final Drawable marker = ( item . getMarker ( state ) == null ) ? getDefau...
Draws an item located at the provided screen coordinates to the canvas .
153,128
public List < Item > getDisplayedItems ( ) { final List < Item > result = new ArrayList < > ( ) ; if ( mInternalItemDisplayedList == null ) { return result ; } for ( int i = 0 ; i < mInternalItemDisplayedList . length ; i ++ ) { if ( mInternalItemDisplayedList [ i ] ) { result . add ( getItem ( i ) ) ; } } return resul...
Get the list of all the items that are currently drawn on the canvas . The obvious use case is a share or export button on a map restricted to what is displayed . The order of the items is kept
153,129
protected Rect calculateItemRect ( Item item , Point coords , Rect reuse ) { final Rect out = reuse != null ? reuse : new Rect ( ) ; HotspotPlace hotspot = item . getMarkerHotspot ( ) ; if ( hotspot == null ) { hotspot = HotspotPlace . BOTTOM_CENTER ; } final int state = ( mDrawFocusedItem && ( mFocusedItem == item ) ?...
Calculates the screen rect for an item .
153,130
private Overlay createPolygon ( BoundingBox key , Integer value , int redthreshold , int orangethreshold ) { Polygon polygon = new Polygon ( mMapView ) ; if ( value < orangethreshold ) polygon . setFillColor ( Color . parseColor ( alpha + yellow ) ) ; else if ( value < redthreshold ) polygon . setFillColor ( Color . pa...
converts the bounding box into a color filled polygon
153,131
public boolean isInClipArea ( final long pX , final long pY ) { return pX > mXMin && pX < mXMax && pY > mYMin && pY < mYMax ; }
Check if a point is in the clip area
153,132
private boolean intersection ( final long pX0 , final long pY0 , final long pX1 , final long pY1 , final long pX2 , final long pY2 , final long pX3 , final long pY3 ) { return SegmentIntersection . intersection ( pX0 , pY0 , pX1 , pY1 , pX2 , pY2 , pX3 , pY3 , mOptimIntersection ) ; }
Intersection of two segments
153,133
private boolean intersection ( final long pX0 , final long pY0 , final long pX1 , final long pY1 ) { return intersection ( pX0 , pY0 , pX1 , pY1 , mXMin , mYMin , mXMin , mYMax ) || intersection ( pX0 , pY0 , pX1 , pY1 , mXMax , mYMin , mXMax , mYMax ) || intersection ( pX0 , pY0 , pX1 , pY1 , mXMin , mYMin , mXMax , m...
Intersection of a segment with the 4 segments of the clip area
153,134
private int getClosestCorner ( final long pX0 , final long pY0 , final long pX1 , final long pY1 ) { double min = Double . MAX_VALUE ; int corner = 0 ; for ( int i = 0 ; i < cornerX . length ; i ++ ) { final double distance = Distance . getSquaredDistanceToSegment ( cornerX [ i ] , cornerY [ i ] , pX0 , pY0 , pX1 , pY1...
Gets the clip area corner which is the closest to the given segment
153,135
public void animateTo ( int x , int y ) { if ( ! mMapView . isLayoutOccurred ( ) ) { mReplayController . animateTo ( x , y ) ; return ; } if ( ! mMapView . isAnimating ( ) ) { mMapView . mIsFlinging = false ; final int xStart = ( int ) mMapView . getMapScrollX ( ) ; final int yStart = ( int ) mMapView . getMapScrollY (...
Start animating the map towards the given point .
153,136
public void setCenter ( final IGeoPoint point ) { if ( ! mMapView . isLayoutOccurred ( ) ) { mReplayController . setCenter ( point ) ; return ; } mMapView . setExpectedCenter ( point ) ; }
Set the map view to the given center . There will be no animation .
153,137
public void stopAnimation ( final boolean jumpToTarget ) { if ( ! mMapView . getScroller ( ) . isFinished ( ) ) { if ( jumpToTarget ) { mMapView . mIsFlinging = false ; mMapView . getScroller ( ) . abortAnimation ( ) ; } else stopPanning ( ) ; } if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ) { fi...
Stops a running animation .
153,138
public void runCleanupOperation ( ) { final SQLiteDatabase db = getDb ( ) ; if ( db == null || ! db . isOpen ( ) ) { if ( Configuration . getInstance ( ) . isDebugMode ( ) ) { Log . d ( IMapView . LOGTAG , "Finished init thread, aborted due to null database reference" ) ; } return ; } createIndex ( db ) ; final long db...
this could be a long running operation don t run on the UI thread unless necessary . This function prunes the database for old or expired tiles .
153,139
public boolean exists ( final String pTileSource , final long pMapTileIndex ) { return 1 == getRowCount ( primaryKey , getPrimaryKeyParameters ( getIndex ( pMapTileIndex ) , pTileSource ) ) ; }
Returns true if the given tile source and tile coordinates exist in the cache
153,140
public boolean purgeCache ( ) { final SQLiteDatabase db = getDb ( ) ; if ( db != null && db . isOpen ( ) ) { try { db . delete ( TABLE , null , null ) ; return true ; } catch ( Exception e ) { Log . w ( IMapView . LOGTAG , "Error purging the db" , e ) ; catchException ( e ) ; } } return false ; }
purges and deletes everything from the cache database
153,141
public boolean remove ( final ITileSource pTileSourceInfo , final long pMapTileIndex ) { final SQLiteDatabase db = getDb ( ) ; if ( db == null || ! db . isOpen ( ) ) { Log . d ( IMapView . LOGTAG , "Unable to delete cached tile from " + pTileSourceInfo . name ( ) + " " + MapTileIndex . toString ( pMapTileIndex ) + ", d...
Removes a specific tile from the cache
153,142
public long getRowCount ( String tileSourceName ) { if ( tileSourceName == null ) { return getRowCount ( null , null ) ; } return getRowCount ( COLUMN_PROVIDER + "=?" , new String [ ] { tileSourceName } ) ; }
Returns the number of tiles in the cache for the specified tile source name
153,143
public long getRowCount ( final String pTileSourceName , final int pZoom , final Collection < Rect > pInclude , final Collection < Rect > pExclude ) { return getRowCount ( getWhereClause ( pZoom , pInclude , pExclude ) + ( pTileSourceName != null ? " and " + COLUMN_PROVIDER + "=?" : "" ) , pTileSourceName != null ? new...
Count cache tiles
153,144
public long getFirstExpiry ( ) { final SQLiteDatabase db = getDb ( ) ; if ( db == null || ! db . isOpen ( ) ) { return 0 ; } try { Cursor cursor = db . rawQuery ( "select min(" + COLUMN_EXPIRES + ") from " + TABLE , null ) ; cursor . moveToFirst ( ) ; long time = cursor . getLong ( 0 ) ; cursor . close ( ) ; return tim...
Returns the expiry time of the tile that expires first .
153,145
public static long getIndex ( final long pMapTileIndex ) { return getIndex ( MapTileIndex . getX ( pMapTileIndex ) , MapTileIndex . getY ( pMapTileIndex ) , MapTileIndex . getZoom ( pMapTileIndex ) ) ; }
Gets the single column index value for a map tile Unluckily map tile index and sql pk don t match
153,146
public long delete ( final String pTileSourceName , final int pZoom , final Collection < Rect > pInclude , final Collection < Rect > pExclude ) { try { final SQLiteDatabase db = getDb ( ) ; if ( db == null || ! db . isOpen ( ) ) { return - 1 ; } return db . delete ( TABLE , getWhereClause ( pZoom , pInclude , pExclude ...
Delete cache tiles
153,147
@ SuppressWarnings ( "unused" ) public boolean onTouchEvent ( MotionEvent event ) { try { int pointerCount = multiTouchSupported ? ( Integer ) m_getPointerCount . invoke ( event ) : 1 ; if ( DEBUG ) Log . i ( "MultiTouch" , "Got here 1 - " + multiTouchSupported + " " + mMode + " " + handleSingleTouchEvents + " " + poin...
Process incoming touch events
153,148
public List < GeopackageRasterTileSource > getTileSources ( ) { List < GeopackageRasterTileSource > srcs = new ArrayList < > ( ) ; List < String > databases = manager . databases ( ) ; for ( int i = 0 ; i < databases . size ( ) ; i ++ ) { GeoPackage open = manager . open ( databases . get ( i ) ) ; List < String > tile...
returns ALL available raster tile sources for all imported geopackage databases
153,149
public ClickableIconOverlay set ( int id , IGeoPoint position , Drawable icon , DataType data ) { set ( position , icon ) ; mId = id ; mData = data ; return this ; }
used to recycle this
153,150
public JSONObject makeHttpRequest ( String url ) throws IOException { InputStream is = null ; JSONObject jObj = null ; String json = null ; try { is = new URL ( url ) . openStream ( ) ; } catch ( Exception ex ) { Log . d ( "Networking" , ex . getLocalizedMessage ( ) ) ; throw new IOException ( "Error connecting" ) ; } ...
by making HTTP POST or GET method
153,151
public static double getCenterLongitude ( final double pWest , final double pEast ) { double longitude = ( pEast + pWest ) / 2.0 ; if ( pEast < pWest ) { longitude += 180 ; } return org . osmdroid . views . MapView . getTileSystem ( ) . cleanLongitude ( longitude ) ; }
Compute the center of two longitudes Taking into account the case when west is on the right and east is on the left
153,152
public BoundingBox increaseByScale ( final float pBoundingboxPaddingRelativeScale ) { if ( pBoundingboxPaddingRelativeScale <= 0 ) throw new IllegalArgumentException ( "pBoundingboxPaddingRelativeScale must be positive" ) ; final TileSystem tileSystem = org . osmdroid . views . MapView . getTileSystem ( ) ; final doubl...
Scale this bounding box by a given factor .
153,153
public void onMapReady ( GoogleMap googleMap ) { mMap = googleMap ; LatLng sydney = new LatLng ( - 34 , 151 ) ; mMap . addMarker ( new MarkerOptions ( ) . position ( sydney ) . title ( "Marker in Sydney" ) ) ; mMap . moveCamera ( CameraUpdateFactory . newLatLng ( sydney ) ) ; }
Manipulates the map once available . This callback is triggered when the map is ready to be used . This is where we can add markers or lines add listeners or move the camera . In this case we just add a marker near Sydney Australia . If Google Play services is not installed on the device the user will be prompted to in...
153,154
public static WMSEndpoint parse ( InputStream inputStream ) throws Exception { DocumentBuilderFactory dbFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder dBuilder = dbFactory . newDocumentBuilder ( ) ; dBuilder . setEntityResolver ( new EntityResolver ( ) { public InputSource resolveEntity ( String p...
note the input stream remains open after calling this method closing it is the caller s problem
153,155
public static boolean isGoogleMapsV2Supported ( final Context aContext ) { try { int resultCode = GooglePlayServicesUtil . isGooglePlayServicesAvailable ( aContext ) ; if ( resultCode == ConnectionResult . SUCCESS ) { final ActivityManager activityManager = ( ActivityManager ) aContext . getSystemService ( Context . AC...
Check whether Google Maps v2 is supported on this device .
153,156
private boolean isSymbolicDirectoryLink ( final File pParentDirectory , final File pDirectory ) { try { final String canonicalParentPath1 = pParentDirectory . getCanonicalPath ( ) ; final String canonicalParentPath2 = pDirectory . getCanonicalFile ( ) . getParent ( ) ; return ! canonicalParentPath1 . equals ( canonical...
Checks to see if it appears that a directory is a symbolic link . It does this by comparing the canonical path of the parent directory and the parent directory of the directory s canonical path . If they are equal then they come from the same true parent . If not then pDirectory is a symbolic link . If we get an except...
153,157
private void cutCurrentCache ( ) { final File lock = Configuration . getInstance ( ) . getOsmdroidTileCache ( ) ; synchronized ( lock ) { if ( mUsedCacheSpace > Configuration . getInstance ( ) . getTileFileSystemCacheTrimBytes ( ) ) { Log . d ( IMapView . LOGTAG , "Trimming tile cache from " + mUsedCacheSpace + " to " ...
If the cache size is greater than the max then trim it down to the trim level . This method is synchronized so that only one thread can run it at a time .
153,158
public static Bitmap getTileBitmap ( final int pTileSizePx ) { final Bitmap bitmap = BitmapPool . getInstance ( ) . obtainSizedBitmapFromPool ( pTileSizePx , pTileSizePx ) ; if ( bitmap != null ) { return bitmap ; } return Bitmap . createBitmap ( pTileSizePx , pTileSizePx , Bitmap . Config . ARGB_8888 ) ; }
Try to get a tile bitmap from the pool otherwise allocate a new one
153,159
private GeoPoint getLocation ( ) { NetworkInfo activeNetwork = cm . getActiveNetworkInfo ( ) ; boolean isConnected = activeNetwork != null && activeNetwork . isConnectedOrConnecting ( ) ; GeoPoint pt = null ; if ( isConnected ) { try { JSONObject jsonObject = json . makeHttpRequest ( url_select ) ; JSONObject iss_posit...
HTTP callout to get a JSON document that represents the IIS s current location
153,160
public void addGreatCircle ( final GeoPoint startPoint , final GeoPoint endPoint ) { final int greatCircleLength = ( int ) startPoint . distanceToAsDouble ( endPoint ) ; final int numberOfPoints = greatCircleLength / 100000 ; addGreatCircle ( startPoint , endPoint , numberOfPoints ) ; }
Draw a great circle . Calculate a point for every 100km along the path .
153,161
public void addGreatCircle ( final GeoPoint startPoint , final GeoPoint endPoint , final int numberOfPoints ) { final double lat1 = startPoint . getLatitude ( ) * Math . PI / 180 ; final double lon1 = startPoint . getLongitude ( ) * Math . PI / 180 ; final double lat2 = endPoint . getLatitude ( ) * Math . PI / 180 ; fi...
Draw a great circle .
153,162
public void draw ( final Canvas canvas , final Projection pj ) { final int size = this . mPoints . size ( ) ; if ( size < 2 ) { return ; } while ( this . mPointsPrecomputed < size ) { final PointL pt = this . mPoints . get ( this . mPointsPrecomputed ) ; pj . toProjectedPixels ( pt . x , pt . y , pt ) ; this . mPointsP...
This method draws the line . Note - highly optimized to handle long paths proceed with care . Should be fine up to 10K points .
153,163
public void enableFollowLocation ( ) { mIsFollowing = true ; if ( isMyLocationEnabled ( ) ) { Location location = mMyLocationProvider . getLastKnownLocation ( ) ; if ( location != null ) { setLocation ( location ) ; } } if ( mMapView != null ) { mMapView . postInvalidate ( ) ; } }
Enables follow functionality . The map will center on your current location and automatically scroll as you move . Scrolling the map in the UI will disable .
153,164
public boolean runOnFirstFix ( final Runnable runnable ) { if ( mMyLocationProvider != null && mLocation != null ) { new Thread ( runnable ) . start ( ) ; return true ; } else { mRunOnFirstFix . addLast ( runnable ) ; return false ; } }
Queues a runnable to be executed as soon as we have a location fix . If we already have a fix we ll execute the runnable immediately and return true . If not we ll hang on to the runnable and return false ; as soon as we get a location fix we ll run it in in a new thread .
153,165
public boolean hasTile ( final long pMapTileIndex ) { ITileSource tileSource = mTileSource . get ( ) ; if ( tileSource == null ) { return false ; } return mWriter . getExpirationTimestamp ( tileSource , pMapTileIndex ) != null ; }
returns true if the given tile for the current map source exists in the cache db
153,166
public static String retrieveKey ( final Context aContext , final String aKey ) { final PackageManager pm = aContext . getPackageManager ( ) ; try { final ApplicationInfo info = pm . getApplicationInfo ( aContext . getPackageName ( ) , PackageManager . GET_META_DATA ) ; if ( info . metaData == null ) { Log . i ( IMapVi...
Retrieve a key from the manifest meta data or empty string if not found .
153,167
public boolean forceLoadTile ( final OnlineTileSourceBase tileSource , final long pMapTileIndex ) { try { final Drawable drawable = mTileDownloader . downloadTile ( pMapTileIndex , mTileWriter , tileSource ) ; return drawable != null ; } catch ( CantContinueException e ) { return false ; } }
Actual tile download regardless of the tile being already present in the cache
153,168
public boolean isTileToBeDownloaded ( final ITileSource pTileSource , final long pMapTileIndex ) { final Long expiration = mTileWriter . getExpirationTimestamp ( pTileSource , pMapTileIndex ) ; if ( expiration == null ) { return true ; } final long now = System . currentTimeMillis ( ) ; return now > expiration ; }
Should we download this tile? either because it s not cached yet or because it s expired
153,169
static IterableWithSize < Long > getTilesCoverageIterable ( final BoundingBox pBB , final int pZoomMin , final int pZoomMax ) { final MapTileAreaList list = new MapTileAreaList ( ) ; for ( int zoomLevel = pZoomMin ; zoomLevel <= pZoomMax ; zoomLevel ++ ) { list . getList ( ) . add ( new MapTileArea ( ) . set ( zoomLeve...
Iterable returning tiles covered by the bounding box sorted by ascending zoom level
153,170
public static List < Long > getTilesCoverage ( final ArrayList < GeoPoint > pGeoPoints , final int pZoomMin , final int pZoomMax ) { final List < Long > result = new ArrayList < > ( ) ; for ( int zoomLevel = pZoomMin ; zoomLevel <= pZoomMax ; zoomLevel ++ ) { final Collection < Long > resultForZoom = getTilesCoverage (...
Computes the theoretical tiles covered by the list of points
153,171
public CacheManagerTask downloadAreaAsync ( Context ctx , ArrayList < GeoPoint > geoPoints , final int zoomMin , final int zoomMax , final CacheManagerCallback callback ) { final CacheManagerTask task = new CacheManagerTask ( this , getDownloadingAction ( ) , geoPoints , zoomMin , zoomMax ) ; task . addCallback ( callb...
Download in background all tiles covered by the GePoints list in osmdroid cache .
153,172
public CacheManagerTask downloadAreaAsyncNoUI ( Context ctx , BoundingBox bb , final int zoomMin , final int zoomMax , final CacheManagerCallback callback ) { final CacheManagerTask task = new CacheManagerTask ( this , getDownloadingAction ( ) , bb , zoomMin , zoomMax ) ; task . addCallback ( callback ) ; execute ( tas...
Download in background all tiles of the specified area in osmdroid cache without a user interface .
153,173
public void cancelAllJobs ( ) { Iterator < CacheManagerTask > iterator = mPendingTasks . iterator ( ) ; while ( iterator . hasNext ( ) ) { CacheManagerTask next = iterator . next ( ) ; next . cancel ( true ) ; } mPendingTasks . clear ( ) ; }
cancels all tasks
153,174
public CacheManagerTask downloadAreaAsync ( Context ctx , List < Long > pTiles , final int zoomMin , final int zoomMax ) { final CacheManagerTask task = new CacheManagerTask ( this , getDownloadingAction ( ) , pTiles , zoomMin , zoomMax ) ; task . addCallback ( getDownloadingDialog ( ctx , task ) ) ; return execute ( t...
Download in background all tiles of the specified area in osmdroid cache .
153,175
public CacheManagerTask cleanAreaAsync ( final Context ctx , ArrayList < GeoPoint > geoPoints , int zoomMin , int zoomMax ) { BoundingBox extendedBounds = extendedBoundsFromGeoPoints ( geoPoints , zoomMin ) ; return cleanAreaAsync ( ctx , extendedBounds , zoomMin , zoomMax ) ; }
Remove all cached tiles covered by the GeoPoints list .
153,176
public static long updateStoragePrefreneces ( Context ctx ) { Configuration . getInstance ( ) . load ( ctx , PreferenceManager . getDefaultSharedPreferences ( ctx ) ) ; File dbFile = new File ( Configuration . getInstance ( ) . getOsmdroidTileCache ( ) . getAbsolutePath ( ) + File . separator + SqlTileWriter . DATABASE...
refreshes the current osmdroid cache paths with user preferences plus soe logic to work around file system permissions on api23 devices . it s primarily used for out android tests .
153,177
private void updateStorageInfo ( ) { long cacheSize = updateStoragePrefreneces ( this ) ; TextView tv = findViewById ( R . id . sdcardstate_value ) ; final String state = Environment . getExternalStorageState ( ) ; boolean mSdCardAvailable = Environment . MEDIA_MOUNTED . equals ( state ) ; tv . setText ( ( mSdCardAvail...
gets storage state and current cache size
153,178
public boolean onSingleTapConfirmed ( final MotionEvent event , final MapView mapView ) { if ( ! mStyle . mClickable ) return false ; float hyp ; Float minHyp = null ; int closest = - 1 ; Point tmp = new Point ( ) ; Projection pj = mapView . getProjection ( ) ; for ( int i = 0 ; i < mPointList . size ( ) ; i ++ ) { if ...
Default action on tap is to select the nearest point .
153,179
public void setSelectedPoint ( Integer toSelect ) { if ( toSelect == null || toSelect < 0 || toSelect >= mPointList . size ( ) ) mSelectedPoint = null ; else mSelectedPoint = toSelect ; }
Sets the highlighted point . App must invalidate the MapView .
153,180
static public ImageryMetaDataResource getInstanceFromJSON ( final String a_jsonContent ) throws Exception { if ( a_jsonContent == null ) { throw new Exception ( "JSON to parse is null" ) ; } final JSONObject jsonResult = new JSONObject ( a_jsonContent ) ; final int statusCode = jsonResult . getInt ( STATUS_CODE ) ; if ...
Parse a JSON string containing ImageryMetaData response
153,181
public static void registerArchiveFileProvider ( Class < ? extends IArchiveFile > provider , String fileExtension ) { extensionMap . put ( fileExtension , provider ) ; }
Registers a custom archive file provider
153,182
private static void load ( final SharedPreferences pPrefs , final Map < String , String > pMap , final String pPrefix ) { if ( pPrefix == null || pMap == null ) return ; pMap . clear ( ) ; for ( final String key : pPrefs . getAll ( ) . keySet ( ) ) { if ( key != null && key . startsWith ( pPrefix ) ) { pMap . put ( key...
Loading a map from preferences using a prefix for the prefs keys
153,183
private static void save ( final SharedPreferences pPrefs , final SharedPreferences . Editor pEdit , final Map < String , String > pMap , final String pPrefix ) { for ( final String key : pPrefs . getAll ( ) . keySet ( ) ) { if ( key . startsWith ( pPrefix ) ) { pEdit . remove ( key ) ; } } for ( final Map . Entry < St...
Saving a map into preferences using a prefix for the prefs keys
153,184
public static void retrieveCloudmadeKey ( final Context aContext ) { mAndroidId = Settings . Secure . getString ( aContext . getContentResolver ( ) , Settings . Secure . ANDROID_ID ) ; mKey = ManifestUtil . retrieveKey ( aContext , CLOUDMADE_KEY ) ; final SharedPreferences pref = PreferenceManager . getDefaultSharedPre...
Retrieve the key from the manifest and store it for later use .
153,185
public static String getCloudmadeToken ( ) { if ( mToken . length ( ) == 0 ) { synchronized ( mToken ) { if ( mToken . length ( ) == 0 ) { final String url = "http://auth.cloudmade.com/token/" + mKey + "?userid=" + mAndroidId ; HttpURLConnection urlConnection = null ; BufferedReader br = null ; InputStreamReader is = n...
Get the token from the Cloudmade server .
153,186
private static double [ ] getStartEndPointsWE ( double west , double east , int zoom ) { double incrementor = getIncrementor ( zoom ) ; if ( zoom < 10 ) { double we_startpoint = Math . floor ( west ) ; double x = 180 ; while ( x > we_startpoint ) x = x - incrementor ; we_startpoint = x ; double ws_stoppoint = Math . ce...
gets the start and stop point for a longitude line
153,187
public static void setDefaults ( ) { lineColor = Color . BLACK ; fontColor = Color . WHITE ; backgroundColor = Color . BLACK ; lineWidth = 1f ; fontSizeDp = 32 ; DEBUG = false ; DEBUG2 = false ; }
resets the settings
153,188
public List < SourceCount > getSources ( ) { final SQLiteDatabase db = getDb ( ) ; List < SourceCount > ret = new ArrayList < > ( ) ; if ( db == null ) { return ret ; } Cursor cur = null ; try { cur = db . rawQuery ( "select " + COLUMN_PROVIDER + ",count(*) " + ",min(length(" + COLUMN_TILE + ")) " + ",max(length(" + CO...
gets all the tiles sources that we have tiles for in the cache database and their counts
153,189
public boolean isCloseTo ( GeoPoint point , double tolerance , MapView mapView ) { return getCloseTo ( point , tolerance , mapView ) != null ; }
Detection is done is screen coordinates .
153,190
protected void setDefaultInfoWindowLocation ( ) { int s = mOriginalPoints . size ( ) ; if ( s > 0 ) mInfoWindowLocation = mOriginalPoints . get ( s / 2 ) ; else mInfoWindowLocation = new GeoPoint ( 0.0 , 0.0 ) ; }
Internal method used to ensure that the infowindow will have a default position in all cases so that the user can call showInfoWindow even if no tap occured before . Currently set the position on the middle point of the polyline .
153,191
public void onDetach ( ) { this . getOverlayManager ( ) . onDetach ( this ) ; mTileProvider . detach ( ) ; mOldZoomController . setVisible ( false ) ; if ( mZoomController != null ) { mZoomController . onDetach ( ) ; } if ( mTileRequestCompleteHandler instanceof SimpleInvalidationHandler ) { ( ( SimpleInvalidationHandl...
destroys the map view all references to listeners all overlays etc
153,192
private static boolean parallelSideEffect ( final double pXA , final double pYA , final double pXB , final double pYB , final double pXC , final double pYC , final double pXD , final double pYD , final PointL pIntersection ) { if ( pXA == pXB ) { return parallelSideEffectSameX ( pXA , pYA , pXB , pYB , pXC , pYC , pXD ...
When the segments are parallels and overlap the middle of the overlap is considered as the intersection
153,193
private static boolean check ( final double pXA , final double pYA , final double pXB , final double pYB , final double pXC , final double pYC , final double pXD , final double pYD , final PointL pIntersection , final double pXI , final double pYI ) { if ( pXI < Math . min ( pXA , pXB ) || pXI > Math . max ( pXA , pXB ...
Checks if computed intersection is valid and sets output accordingly
153,194
private static boolean divisionByZeroSideEffect ( final double pXA , final double pYA , final double pXB , final double pYB , final double pXC , final double pYC , final double pXD , final double pYD , final PointL pIntersection ) { return divisionByZeroSideEffectX ( pXA , pYA , pXB , pYB , pXC , pYC , pXD , pYD , pInt...
Main intersection formula works only without division by zero
153,195
public boolean onSingleTapConfirmed ( final MotionEvent event , final MapView mapView ) { return ( activateSelectedItems ( event , mapView , new ActiveItem ( ) { public boolean run ( final int index ) { final ItemizedIconOverlay < Item > that = ItemizedIconOverlay . this ; if ( that . mOnItemGestureListener == null ) {...
Each of these methods performs a item sensitive check . If the item is located its corresponding method is called . The result of the call is returned .
153,196
private boolean activateSelectedItems ( final MotionEvent event , final MapView mapView , final ActiveItem task ) { final int eventX = Math . round ( event . getX ( ) ) ; final int eventY = Math . round ( event . getY ( ) ) ; for ( int i = 0 ; i < this . mItemList . size ( ) ; ++ i ) { if ( isEventOnItem ( getItem ( i ...
When a content sensitive action is performed the content item needs to be identified . This method does that and then performs the assigned task on that item .
153,197
public void garbageCollection ( ) { int toBeRemoved = Integer . MAX_VALUE ; final int size = mCachedTiles . size ( ) ; if ( ! mStressedMemory ) { toBeRemoved = size - mCapacity ; if ( toBeRemoved <= 0 ) { return ; } } refreshAdditionalLists ( ) ; if ( mAutoEnsureCapacity ) { final int target = mMapTileArea . size ( ) +...
Removes from the memory cache all the tiles that should no longer be there
153,198
private void populateSyncCachedTiles ( final MapTileList pList ) { synchronized ( mCachedTiles ) { pList . ensureCapacity ( mCachedTiles . size ( ) ) ; pList . clear ( ) ; for ( final long index : mCachedTiles . keySet ( ) ) { pList . put ( index ) ; } } }
Just a helper method in order to parse all indices without concurrency side effects
153,199
public boolean startOrientationProvider ( IOrientationConsumer orientationConsumer ) { mOrientationConsumer = orientationConsumer ; boolean result = false ; final Sensor sensor = mSensorManager . getDefaultSensor ( Sensor . TYPE_ORIENTATION ) ; if ( sensor != null ) { result = mSensorManager . registerListener ( this ,...
Enable orientation updates from the internal compass sensor and show the compass .