Skip to content

Instantly share code, notes, and snippets.

@nutiteq
nutiteq / TmsMapLayerNoCache.java
Created August 7, 2013 06:26
Nutiteq SDK online tile layer which does not cache permanently
package com.nutiteq.layers.raster;
import java.util.Map;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.nutiteq.components.Components;
import com.nutiteq.components.MapTile;
import com.nutiteq.log.Log;
@nutiteq
nutiteq / GetFeatureInfoListener.java
Created March 4, 2013 10:10
How to have GetFeatureInfo URL for Nutiteq SDK
@Override
public void onMapClicked(double x, double y, boolean longClick) {
// your activity should have getter for the MapView
MapView map = ((TesterMap3DActivity) mapActivity).getMapView();
float zoom = map.getZoom();
double worldSize = 360.0; // for EPSG3857: Math.PI * 6378137.0f * 2.0f;
double tileSizeHalf = worldSize / Math.pow(2,zoom) / 2.0;
double wgsX = (new EPSG3857()).toWgs84(x, y).x;
@nutiteq
nutiteq / SqliteXYTextLayer.java
Created January 28, 2013 21:33
SqliteXYTextLayer.java - Layer sample, takes texts from SQLite database.
/*
Layer which reads text,x,y from SQLite database and shows labels in given coordinates. x and y must be in layer projection,
which means EPSG:3857 (spherical mercator), or you can use projection.fromWgs() of to convert it.
Note that with layer definition you give database file name and SQL which must return x, y and text - in this order,
also filter arguments must be in same number and order (xmin,xmax,ymin,ymax). Do not use this for big datasets, as this query
is not indexed properly and will become slow with thousands of rows. Use Spatialite for big datasets, as it can do spatial indexes
and fast reading from tables with millions of items (e.g. global geonames.org database dump).
Usage sample reading from a table "NamesTable" with columns mappos_x,mappos_y,name :
@nutiteq
nutiteq / NetFetchTileTask.java
Created October 29, 2012 21:04
NetFetchTileTask.java
package com.nutiteq.tasks;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@nutiteq
nutiteq / SimpleScaleBar.java
Created October 23, 2012 19:45
SimpleScaleBar.java (Nutiteq old SDK)
package com.nutiteq.ui;
import henson.midp.Float11;
import com.nutiteq.wrappers.Font;
import com.nutiteq.wrappers.Graphics;
@nutiteq
nutiteq / WfsTask.java
Created October 19, 2012 14:24
WfsTask.java - geometry layer sample task
package com.nutiteq.app.layers;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.LinkedList;
@nutiteq
nutiteq / TMSMapLayer.java
Created October 19, 2012 09:51
TMSMapLayer.java
package com.nutiteq.rasterlayers;
/**
* A raster layer class that uses an URL as a source for the map tile data. The request are generate in this manner:
* <p>
* <p>
* baseUrl + zoom + separator + x + separator + y + format
* <p>
* <p>
* For example if: baseUrl = "http://tile.openstreetmap.org/", separator = "/", format = ".png"
package com.nutiteq.app.layers;
import com.nutiteq.components.MapPos;
import com.vividsolutions.jts.geom.Envelope;
public class TileUtils {
private static final double TILESIZE = 256;
private static final double initialResolution = 2.0f * Math.PI * 6378137.0f
/ TILESIZE;
@nutiteq
nutiteq / LabelOverlayListener.java
Created October 6, 2012 18:28
Nutiteq map SDK label sample
package com.nutiteq.app.listeners;
import javax.microedition.khronos.opengles.GL10;
import org.json.JSONObject;
import android.app.Activity;
import android.view.View;
import android.webkit.WebView;
@nutiteq
nutiteq / WikipediaTask.java
Created October 6, 2012 18:10
Wikipedia Layer for Nutiteq 3D maps SDK - task to download data
package com.nutiteq.app.layers;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import org.json.JSONArray;