WMTS layer not showing in ArcGis Android runtime 100.2.0 - arcgis

Using the Android Runtime API 100.2.0, I would like to add a WMTS layer as a basemap. Unfortunately the layer is not showing in the map. The WMTS service url is https://geodata.nationaalgeoregister.nl/tiles/service/wmts?request=getcapabilities. It seems to be available in Key Value Pairs (KVP) encoding only. One of the layers in this WMTS service is the one I would like to use as a basemap: "top100raster". The spatial reference is Amersfoort / RD New: EPSG Projection -- Spatial Reference (http://spatialreference.org/ref/epsg/amersfoort-rd-new/).
Activity code:
private SpatialReference spatialReference = SpatialReference.create(28992);
private double[] bbox = new double[]{646.36, 308975.28, 276050.82, 636456.31};
mapView = (MapView) findViewById(R.id.map);
mapView.setViewpoint(new Viewpoint(new Envelope(bbox[0], bbox[1], bbox[2], bbox[3], spatialReference)));
ArcGISMap map = new ArcGISMap(spatialReference);
mapView.setMap(map);
WmtsLayer wmtsLayer = new WmtsLayer("https://geodata.nationaalgeoregister.nl/tiles/service/wmts?", "top100raster"));
Basemap baseMap = new Basemap(wmtsLayer);
map.setBasemap(baseMap);
There are no errors in the project, also it compiles and runs without errors. The map however is empty :-(
What am I missing here?

Problem solved... the modified code below works.
private SpatialReference spatialReference = SpatialReference.create(28992);
private double[] bbox = new double[]{646.36, 308975.28, 276050.82, 636456.31};
mapView = (MapView) findViewById(R.id.map);
ArcGISMap map = new ArcGISMap(spatialReference);
map.setInitialViewpoint(new Viewpoint(new Envelope(bbox[0], bbox[1], bbox[2], bbox[3], spatialReference)));
WmtsLayer wmtsLayer = new WmtsLayer("https://geodata.nationaalgeoregister.nl/tiles/service/wmts?request=GetCapabilities&service=WMTS", "top100raster");
Basemap baseMap = new Basemap(wmtsLayer);
map.setBasemap(baseMap);
mapView.setMap(map);

Related

Benefit of using CreateProxy<UserAccount>() vs new UserAccount()

Using Entity Framework Core with Lazy Loading Proxies, I have a UserAccount Model which has a property "LocalizationId" and a Lazy Load Navigation Property "Localization".
What benefit is there to using DatabaseContext.CreateProxy<UserAccount>() vs new UserAccount()?
In both cases, once the model is added to the DatabaseContext, and the Id of the Navigation property is set, the Navigation Property is Lazy Loaded and changes are tracked as expected...
var model = new Models.UserAccount()
{
LocalizationId = 1
};
DatabaseContext.Add(model);
var proxy = DatabaseContext.CreateProxy<Models.UserAccount>();
DatabaseContext.Add(proxy);
proxy.LocalizationId = 1;
var proxyLocalization = proxy.Localization.Name;
var modelLocalization = model.Localization.Name;
I feel like I have to be missing something obvious, because I don't see the benefit to using CreateProxy.
Difference that object created by CreateProxy can load related entity later instead of.
You have the same result in both objects because var proxyLocalization = proxy.Localization.Name have loaded Localization object and added to change tracker. Change tracker have found your non-proxied object and initialized automatically related property.

ABCPDF 8 - How can I get the name of each layer in a PDF?

I have a process that receives unlayered and layered PDF files. For the unlayered PDF files, I'll add a layer named "cut". For the layered PDF files, I need to check to see if there is already a layer named "cut" and if so, do not add the "cut" layer. Using ABCPDF 8, how can I get the names of all the layers in a PDF to determine if there is a layer named "cut"?
I found iTextSharp has an easy way to get the names of the layers. Here is a snippet of code on how to do it:
tempOutputFile = System.IO.Path.GetTempFileName();
iTextSharp.text.pdf.PdfReader pdfReader = new iTextSharp.text.pdf.PdfReader(pdfFile);
iTextSharp.text.pdf.PdfStamper pdfStamper = new iTextSharp.text.pdf.PdfStamper(pdfReader, new System.IO.FileStream(tempOutputFile, System.IO.FileMode.Create));
System.Collections.Generic.Dictionary<string, iTextSharp.text.pdf.PdfLayer> layers = pdfStamper.GetPdfLayers();
pdfStamper.Close();
pdfReader.Close();
System.IO.File.Delete(tempOutputFile);
The key for the layers dictionary is the name of the layer. Easy as that!
ABCpdf Version 10 contains a project called OCGLayers which shows you how to do this.
For example to get all the named layers you would use code of the following form:
Page page = ... get a page ...
List<Group> groups = oc.GetGroups(page);
List<int> indents = new List<int>();
oc.SortGroupsForPresentation(groups, indents);
for (int i = 0; i < groups.Count; i++) {
Group group = groups[i];
string indent = new string(' ', indents[i] * 3);
layersCheckedListBox.Items.Add(indent + group.EntryName.Text, group.Visible);
}
The project also contains code showing how to redact layers. This may be useful given your described task.
public Dictionary<String, PdfLayer> GetPdfLayerNames()
{
PdfReader reader1 = new PdfReader("D:\\pdf\\ClaimOut4e0907cbdb6845549458e82900db7be0.pdf");
PdfStamper stamper1 = new PdfStamper(reader1, new FileStream("D:\\new_stamper.pdf", FileMode.Append));
Dictionary<String, PdfLayer> layers = stamper1.GetPdfLayers();
stamper1.Close();
reader1.Close();
return layers;
}
Using this you can get names of all layers from Pdf Where sting in dictionary is name of Layer within pdf

SharpDX: Enabling BlendState

I'm trying to get the "SharpDX.Direct3D11.DeviceContext.OutputMerger.Blendstate" to work. Without this, i have nice scene (Polygones with textures on it, for a Spaceshooter). I've done OpenGL Graphics in the past three years, so i thought it might be as simple as in OpenGL - just enable Blending and set the right Dst/Src Modes. But if i set a new BlendStateDescription, all Output is Black, even if "RenderTarget[x].IsBlendEnabled" is set to "false".
I searched for a tutorial or something, and find one - but it uses effects. So my question is simple - do i have to use technique's and effects in SharpDX? No other way left for simple blending?
This is what i've done:
mBackBuffer = Texture2D.FromSwapChain<Texture2D>(mSwapChain, 0);
mRenderView = new RenderTargetView(mDevice, mBackBuffer);
mContext.OutputMerger.SetTargets(mDepthStencilView, mRenderView);
mContext.OutputMerger.SetBlendState(new BlendState(mDevice, new BlendStateDescription()), new SharpDX.Color4(1.0f), -1);
mContext.OutputMerger.BlendState.Description.RenderTarget[0].IsBlendEnabled = true;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].SourceBlend = BlendOption.SourceAlpha;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].DestinationBlend = BlendOption.InverseSourceAlpha;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].BlendOperation = BlendOperation.Add;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].SourceAlphaBlend = BlendOption.One;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].DestinationAlphaBlend = BlendOption.Zero;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].AlphaBlendOperation = BlendOperation.Add;
mContext.OutputMerger.BlendState.Description.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
And, even if just simply do:
mContext.OutputMerger.SetBlendState(new BlendState(mDevice, new BlendStateDescription()), new SharpDX.Color4(1.0f), -1);
mContext.OutputMerger.BlendState.Description.RenderTarget[0].IsBlendEnabled = false;
ouput is all black.. maybe i just have to change something in the pixel shaders?
All resource in Direct3D11 are immutable, so when you are creating the new Blendstate(mDevice, new BlendStateDescription()), you cannot change the description later.
The normal workflow is:
var blendDescription = new BlendDescription();
blendDescription.RenderTarget[0].IsBlendEnabled = .. // set all values
[...]
var blendState = new BlendState(device, blendDescription);
context.OutputMerger.SetBlendState(blendState, ...);
Also resource objects need to be stored somewhere and disposed when you are completely done with them (most of the time for blendstates, at the end of your application), otherwise you will get memory leaks.
I advice you to look more closely at some Direct3D11 C++ samples when you are not sure about the API usage. Also, I recommend you to read a book like "Introduction to 3D Game Programming with DirectX 11" by Frank.D.Luna which is perfect to begin and learn the Direct3D11 API.

Image Filter on ROI with Java2D

i want apply some filters [image filter] on Region Of Interest that user selected.
i need API for getting pixels of this area [polygon or freehand also Rectangle] and apply
filter.any Suggestion for this work ?
Basically, what you need to do is:
Create a BufferedImage and link it with a Graphics object
Set clipping region
Draw to this Graphics object
Apply filter on the BufferedImage object
In pseudocode:
private BufferedImage bufferedImage = new BufferedImage()
private Graphics2D graphics = bufferedImage.createGraphics()
void paint(Graphics2D input) {
graphics.clip(selectionArea.getShape())
upperCanvas.paint(graphics)
BufferedImageOp op
bufferedImage = op.filter(bufferedImage, new BufferedImage())
input.drawImage(bufferedImage)
}
For applying filter, see java.awt.image
As you can see, this can be done in java2d, but the API is quite complicated. If you're interested I can suggest pulpcore as a replacement framework. It includes several predefine filters and a one-line-API for apply them. See demo. Also includes a Java2DSprite class for easy porting between pulpcore and java2d.

Instantiate google map object with a defined set of bounds?

I want to create google map using a pre-defined set of bounds.
So instead of the usual:
var map = new GMap2(document.getElementById('map'));
map.setCenter(new GLatLng(0,0),5);
I want to do something like:
var map = new GMap2(document.getElementById('map'));
map.setBounds(new GLatLng(10,10), new GLatLng(20,20));
Is this possible?
Yes, see below:
var map = new GMap2(document.getElementById('map'));
var bounds = new GLatLngBounds(new GLatLng(10,10), new GLatLng(20,20));
map.setCenter(bounds.getCenter());
map.setZoom(map.getBoundsZoomLevel(bounds));