I am currently working on the Venues3D provided by Here-api.
Here is my problem:
I want to put a Marker inside a Venue and ontop of a Space.
Here is a example picture of what I want from the official Here WeGo Android-App.
Example: Marker ontop of Space inside venue
I already checked out the "normal" MapMarkers but they only take GeoCoordinate and not Spaces inside a Venue.
The Venue3DTutorial didn't help too much either. There is a routing option shipped with it that pins the markers when calculating a route between two points inside a venue. But this is done in the background.(Also called Flags)
Is there an other Class that provides this functionality?
Each Space has a center as GeoCoordinate, so you can use it for your marker. You should also specify correct parameters, so the marker will be visible on top of the venue. Here's an example how to do it with a marker similar to the one in HERE WeGo app:
public void showMarker(Space space) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.your_marker_image);
Image image = new Image();
image.setBitmap(bitmap);
m_marker = new MapMarker(space.getCenter(), image);
// Set anchor point to the centre-bottom area of the marker
m_marker.setAnchorPoint(new PointF(image.getWidth() / 2f, image.getHeight()));
m_marker.setOverlayType(MapOverlayType.FOREGROUND_OVERLAY);
m_marker.setZIndex(100);
// You can get map from VenueMapFragment, for example.
getMap().addMapObject(m_marker);
}
Related
Normally in openlayer, if I want to add an image I just create the layer and add it to the map by doing the following:
var map = new OpenLayers.Map(mapCanvas, mapOptions);
var layer = new ImageLayer().add(name, url, envelope, size, this.map);
with this function i can specify the envelope (norteast , northwest, southeast, southwest boundaries) with WGS84. I can also say the size of the image.
Is there anything similar in android studio for GMAPS? Thanks.
as advised by Antonio in the comment, Ground Overlays should do the trick.
I'm using OSMdroid library in my project to display map tiles (it's a shape with lines and blank background) from my company local sever in my app. The thing is when I use the app in offline mode and I browse the map shows an empty grey grid background for the tiles that aren't in the cache, and I want to change that empty grey grid for an blank background image/tile.
The only workaround that I've found to achieve this is the following:
Add a tile overlay and set setLoadingBackgroundColor and setLoadingLineColor to Color.WHITE, and then set the TileSource from the local server from OnlineTileSourceBase. I know this is not quite performant, so is there a better way to do this? Thanks in advance!
final ITileSource tileSource = new OnlineTileSourceBase(...)
{
#Override
public String getTileURLString(MapTile aTile) {
return getBaseUrl() + aTile.getX() + "+" + aTile.getY() + "+" + aTile.getZoomLevel();
}
};
tileProvider = new MapTileProviderBasic(context, tileSource);
tilesOverlay = new TilesOverlay(tileProvider , context);
tilesOverlay.setLoadingBackgroundColor(Color.WHITE);
tilesOverlay.setLoadingLineColor(Color.WHITE);
this.map.getOverlays().add(tilesOverlay);
this.map.setTileSource(tileProvider.getTileSource());
map.invalidate();
Your code is an example on adding a secondary tile overlay. That's useful for when you need another raster graphics overlay on top of the map imagery.
You can also change the loading lines and background for the existing and default tiles overlay. This should get you going
mMapView.getOverlayManager().getTilesOverlay().setLoadingBackgroundColor(Color.TRANSPARENT);
mMapView.getOverlayManager().getTilesOverlay().setLoadingLineColor(Color.TRANSPARENT);
I am fairly new to Java, and so some of the classes like Color Model and JAI are not familiar to me. I have a tiff image I am reading into a program in Java. This is my read-in code:
BufferedImage img = null;
String input[] = {"LE70160412002112EDC00_sr_band5", "LE70160412002144EDC00_sr_band5"};
String filetype = "tif";
File file = new File(input[0] + "output.csv");
int numFiles = 0;
while (numFiles < 2){
if (filetype == "tif"){
FileSeekableStream stream = new FileSeekableStream(new File(input[numFiles] + ".tif"));
TIFFDecodeParam decodeParam = new TIFFDecodeParam();
decodeParam.setDecodePaletteAsShorts(true);
ParameterBlock params = new ParameterBlock();
params.add(stream);
RenderedOp image1 = JAI.create("tiff", params);
img = image1.getAsBufferedImage();
}
}
To be clear, other things are done further down in the while loop that I excluded such that the files are not overwriting each other. The problem I am having is not being able read in the file and get further into the loop. I had a tiff file that only had black and white pixels (0 or 255 red value for all pixels), and the code ran correctly because the file supplied the Color Model. The new tiff file I am trying to use is a greyscale picture (0 to 255 red value for all pixels), and every time I run the code it gives me the following error message:
Exception in thread "main" java.lang.IllegalArgumentException: No ColorModel is supplied and the image ColorModel is null.
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2500)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
at Soda.DoStuff.doStuff(DoStuff.java:60)
at Soda.Driver.main(Driver.java:6)
My first instinct given the error message is to create a new Color Model. There may also be a better way to use JAI to import the tiff file such that it supplies the Color Model for the greyscale image. My end goal is to get the red value for each pixel in the image, so I do not want the data coming in to be altered from it's original form.
Any help I can get would be much appreciated. I am open to any suggestions.
EDIT:
Someone commented to try and use the getDefaultColorModel class inside the PlanarImage library, so I changed the bottom line of the code to this:
cm = PlanarImage.getDefaultColorModel(0, 1); //
img = image1.getAsBufferedImage(null, cm);
This also did not completely work but provided a different error message:
Exception in thread "main" java.lang.IllegalArgumentException: SampleModel and ColorModel parameters must be non-null.
at com.sun.media.jai.util.JDKWorkarounds.areCompatibleDataModels(JDKWorkarounds.java:363)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2505)
at Soda.DoStuff.doStuff(DoStuff.java:64)
at Soda.Driver.main(Driver.java:6)
I have extensively read through https://docs.oracle.com/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/PlanarImage.html to learn about the PlanarImage class, but I still cannot figure out how to properly format a ColorModel. (0,1) creates a color model with 8 pixel bits and 1 component. I also tried with (1,1) which creates a color model with 16 pixel bits and 1 component. Both provided the same error message above.
EDIT2: Unfortunately, I cannot link the image itself. However, I can tell you how I got the image from USGS. Forewarning, getting this image requires you to make a free account, and then afterwards you have to 'order' the picture from USGS, which is simply they need to process the request and give a download link for a zip file. It WILL take some time before you can actually access the picture. I also suggest making the account first because it will not let you start the image checkout process until you have an account made.
Using this link, http://earthexplorer.usgs.gov/, you pick a point on the map, then set the date range so that it ends on 12/31/2002 (the start date does not matter). The go to the Data set tab where under the "Landsat Archive" bullet, you will hit the checkbox for "Landsat Surface Reflectance - L7 ETM+". Hit OK on the dialogue, then hit "Results" at the bottom of the screen.
Once you have signed into your account and done this search, you should see many images on the left side of your screen with similar names to the filenames in my code above. You want to hit the shopping cart next to one of the images (You only need one, my whole project required 2, but for the purposes of reading in the file, that's not necessary). The shopping cart should turn green. Then in the top right corner there is a link to an Item Basket. You hit "Proceed to Checkout" and "Submit Order" on successive screens, and then you wait for an email from USGS.
Finally unzip the file, and you should have about 10 images. As you can see in the code, I am using the image with the name "sr_band5", but I believe any of the bands are greyscale which I cannot read in. Hope this can help.
In my android app, I have a geo-referenced image which I am going to use as map. So I need to divide it into tiles. For that I want its top left and bottom right image coordinate(x,y) with location coordinate of corresponding image coordinates using java codes which is supported in android. Can anyone help me with the solution.
Update:
I got image coordinates of top left and bottom right corners but still I am not getting location coordinate (lat/long) of top left and bottom right corner. lat/long are already embedded in the image as it is already geo-referenced can anyone tell me how to fetch lat/long of the corners from image.
EDIT:
For calculating position of image add this to your activity oncreate and for location coordinates checkout below the exif interface code:
imageView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
pubic void onGlobalLayout() {
int height = imageView.getHeight();
int width = imageView.getWidth();
int x = imageView.getLeft();
int y = imageView.getTop();
//don't forget to remove the listener to prevent being called again by future layout events:
imageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
You can embed EXIF data / set it when taking the picture before sending it to a remote server for processing. When posting / sending the data to a remote system, you could send the location data seperate, or leave it as attributes as part of the EXIF data.
Write/Geotag JPEGs (EXIF data) in Android
From reading the above, my assumption would be that the following would work:
ExifInterface exif;
exif = new ExifInterface("/sdcard/DCIM/"+filename+".jpeg");
double exifLatitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
double exifLongitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
I am working on a project in which user gives us a scanned copy of a form, and we need to identify various fields within the image.
I have a form like this:
The form has four crop marks/ registration marks at four corners of the page. Now the user is supposed to fill the form and give back a scanned copy of his filled form. The scanned form that we get may have been rotated by some angle. For instance see the rotated form below:
Now to extract the exact fields out of form, i.e. to extract any particular field like Title in the scanned form, we need to have exact coordinates but since our image has been rotated by unknown angle. We are unable to do so.
I read about registration marks and their use to align the page to a standard form.
I tried searching for these registration marks in the image, but since it is rotated we may not find the position of the mark in the rotated image.
I tried searching for the issue and found some questions on SO which although gave some direction but couldn't help much.
This Question gave me reference to LEADTools SDK which has functions to perform this tasks. Unfortunately this SDK is not for JAVA and along with that it's proprietary and not free.
Is there any other open source tools for the same purpose.
Additionally I am open to suggestions about other methods used to align the form.
You could use the coordinates of the markers in the corner of the document. Using the coordinates of the corners of the lines, you could measure the rotation angle of the paper in order to compensate it.
The post below addresses a similar issue:
"Image Processing Edge Detection in Java"
Below an approach to detect the coordinates using Java and Marvin.
output (some noise cause of the JPEG compression):
source code:
import marvin.image.MarvinImage;
import marvin.io.MarvinImageIO;
import marvin.util.MarvinAttributes;
import static marvin.MarvinPluginCollection.*;
public class DocumentMarks {
public DocumentMarks(){
MarvinImage image = MarvinImageIO.loadImage("./res/document.jpg");
thresholding(image, 250);
MarvinAttributes ret = moravec(image.clone(), image, 5, 100000);
image = showCorners(image, ret, 4);
MarvinImageIO.saveImage(image, "./res/document_out.jpg");
}
private static MarvinImage showCorners(MarvinImage image, MarvinAttributes attr, int rectSize){
MarvinImage ret = image.clone();
int[][] cornernessMap = (int[][]) attr.get("cornernessMap");
int rsize=0;
for(int x=0; x<cornernessMap.length; x++){
for(int y=0; y<cornernessMap[0].length; y++){
// Is it a corner?
if(cornernessMap[x][y] > 0){
rsize = Math.min(Math.min(Math.min(x, rectSize), Math.min(cornernessMap.length-x, rectSize)), Math.min(Math.min(y, rectSize), Math.min(cornernessMap[0].length-y, rectSize)));
ret.fillRect(x, y, rsize, rsize, Color.red);
}
}
}
return ret;
}
public static void main(String[] args) {
new DocumentMarks();
System.exit(0);
}
}
I successfully identified crop marks in the scanned document. I've described the approach on my blog here.