Hi…
Currently I am display tiff images on map using GeoTiffRasterLayer i.e: below code
Dim i As Integer
Dim MAPA_FOTO(9) As GeoTiffRasterLayer
For i = 1 To 5
MAPA_FOTO(i - 1) = New GeoTiffRasterLayer(Server.MapPath("~\App_Data" + i.ToString() + ".tif"))
Dim proj4 As Proj4Projection = New Proj4Projection()
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32723)
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
proj4.Open()
MAPA_FOTO(i - 1).ImageSource.Projection = proj4
MAPA_FOTO(i - 1).UpperThreshold = Double.MaxValue
MAPA_FOTO(i - 1).LowerThreshold = 0
MAPA_FOTO(i - 1).DrawingQuality = DrawingQuality.HighSpeed
MAPA_FOTO(i - 1).IsGrayscale = False
overlays.LayerOverlay("Images" + i.ToString(), False, TileType.SingleTile).Layer(Images(i - 1)).IsVisible(True).IsVisibleInOverlaySwitcher(False)
Next
Now I am display image on map which are stored in database (SQL Server)
So how can I fetch images from SQL Server and display on map?
Fetch Image from database and display on map
Hi Vivek,
Thanks for your post and welcome to Map Suite Forums!
Sorry the Map Suite doesn’t support rendering tiff images from database currently. I am afraid we still need to export the images on the disk.
Sorry for the inconvenience.
Regards,
Troy
Thankx Trony
Ok then now I have jpeg images in local disk i.e. D:\MapImages<br />
and its coordinates XMin, XMax, YMin and YMax are stored in sql server table with image name column ImageName.
Like in local storage if Image name is 01.11.jpg then in database table
ImageName | XMin | YMin | XMax | YMax
01.11 | 22.22 | 33.33 | 22.25 | 33.35
So how can I display this jpeg images on map at appropriate coordinates saved in database?
My project is in MVC 3
Hi Vivek,
After we have the raster images, then we can do it with an extension class named MultiGeoRasterLayer. Here is a sample to show how to use it:
wiki.thinkgeo.com/wiki/Sourc…090728.zip
Let me do some explanations on the class: In order to use the class, we need to generate a reference file(.txt) whose format is like
// Reference File Format: [UpperLeftPointX],[LowerRightPoint.X],[UpperLeftPoint.Y],[LowerRightPoint.Y],[Path & File Name to Raster]
and we can use it static method “BuildReferenceFile” to generate it.
In the open method, the main job is constructing a R-Tree with each image boundingbox. Then, in the DrawCore method, we can use R-Tree to get the images which are in the current extent.
Comparing with your requirements, I think you just need to generate the reference file by modify the BuildReferenceFile method.
Hope my explanation is clear and helpful.
If more questions, please feel free to let us know.
Regards,
Troy
Thanks Troy…
As you told me “wiki.thinkgeo.com/wiki/Sourc...090728.zip”, I use this code in my project, but I am confuse in one function can you p;z help me??
Function is :
protected override void DrawCore(GeoCanvas canvas, Collection<simplecandidate> labelsInAllLayers)
{
double currentScale = ExtentHelper.GetScale(canvas.CurrentWorldExtent, canvas.Width, canvas.MapUnit);
if (currentScale >= lowerScale && currentScale <= upperScale)
{
RectangleShape currentExtent = canvas.CurrentWorldExtent;
Envelope currentExtentEnvelope = new Envelope(currentExtent.UpperLeftPoint.X, currentExtent.LowerRightPoint.X, currentExtent.UpperLeftPoint.Y, currentExtent.LowerRightPoint.Y);
ArrayList rasters = (ArrayList)spatialIndex.Query(currentExtentEnvelope);
foreach (string file in rasters)
{
GdiPlusRasterLayer rasterRasterLayer = new GdiPlusRasterLayer(file);
rasterRasterLayer.Open();
rasterRasterLayer.Draw(canvas, labelsInAllLayers);
rasterRasterLayer.Close();
}
}
}
How can I call this function, means what parameters I passed to call this function.
As my project in MVC VB.NET, so I convert code into Vb.Net.
I don’t know about “Collection<simplecandidate> labelsInAllLayers”</simplecandidate>
So can you tell me how can I pass geocanvas and labelsInAllLayers for DrawCore function??</simplecandidate>
Hi Vivek,
Actually, You don’t need to care when and how to call the DrawCore method, as it is a base method and will be called in the base class “Layer”. The only thing we need to care is the parameters, in the DrawCore method, the geocanvas means we will draw the features in the canvas and it includes many useful information. As for the labelsInAllLayers, we really don’t need to care.
The similar thing is like the other methods “xxxCore”, all of them are using the same strategy.
Hope it helps.
Regards,
Troy
Thankx for reply
ok now xxxcore methodes are executes.
In code DrawImage() method, What is Map?
Because my project is Web Based in MVC 3,
So what I used instead of Map?
private void DrawImage()
{
if (bitmap != null) { bitmap.Dispose(); }
bitmap = new Bitmap(Map.Width, Map.Height);
mapEngine.OpenAllLayers();
mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree);
mapEngine.CloseAllLayers();
Map.Image = bitmap;
}
Hi Vivek,
We can treat the MultiGeoRasterLayer as a common layer and can be used in any MapSuite product line like Mvc.
Here is the codes for Mvc:
MultiGeoRasterLayer multiGeoRasterLayer =
new
MultiGeoRasterLayer(@
"…\Data\referenceFile.txt"
);
LayerOverlay overlay =
new
LayerOverlay();
overlay.IsBaseOverlay =
true
;
// notice this property
overlay.Layers.Add(multiGeoRasterLayer);
map.CustomOverlays.Add(overlay);
Actually, The DrawImage method you see from the sample is towards for Map Suite Service Edition which only includes the MapSuiteCore.Dll and We don’t need it anymore if you have the Mvc Edition.
Hope it helps and if any questions, don’t hesitate to let us know.
Regards,
Troy
Thanks Troy
Sorry for late response
Ok, I use this function in my project but in old DrawImage()
private void DrawImage()
{
if (bitmap != null) { bitmap.Dispose(); }
bitmap = new Bitmap(Map.Width, Map.Height);
mapEngine.OpenAllLayers();
mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree);
mapEngine.CloseAllLayers();
Map.Image = bitmap;
}
opencore, drawcore and closecore method was call, but using,
MultiGeoRasterLayer multiGeoRasterLayer = new MultiGeoRasterLayer(@"…\Data\referenceFile.txt");
LayerOverlay overlay = new LayerOverlay();
overlay.IsBaseOverlay = true; // notice this property
overlay.Layers.Add(multiGeoRasterLayer);
map.CustomOverlays.Add(overlay);
method no these methods called, so what’s the problem How can I called that methods in MVC Web Application?
because currently using above method, in my map no any effect come.
Hi Vivek,
Would you please try to set the IsBaseOverlay as false in Mvc Edition? I just guess there are some other layers as the base layer. In Web or Mvc Edition, there is only one layerOverlay can be as the base overlay, if there are multi base overlay, then the other overlays would be drawn, which means all the layers in those overlays would’t be called just like your case.
But if the issue is not related with it, would you please attach the codes how you are using in Mvc Application?
Regards,
Troy
Hi, Troy
Yes in my project there are multiple layers are on the map. Layer are using projection code:
Dim M As MsSql2008FeatureLayer = New MsSql2008FeatureLayer(connectString, “M”, “id”, 32723)
M.Open()
M.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
Dim proj2 As Proj4Projection = New Proj4Projection()
proj2.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32723)
proj2.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
proj2.Open()
M.FeatureSource.Projection = proj2
overlays.LayerOverlay(“M”, False, TileType.SingleTile).Layer(M).IsVisible(False)
This code I am using in View while multigeoraster layer I used in controller.
There are more than 5 layers are used as above in the map.
I called controller method from view using ajax:
$(document).ready(function () {
debugger;
var map1 = document.getElementById(“map”); //map is a ID of div tag where whole map is loaded
Map1.ajaxCallAction(’@ViewContext.RouteData.Values(“Controller”).ToString()’, “ImageDisplay”, { map : map1 }, TifCallback);
});
function TifCallback(result) {
Map1.redrawLayer(“multigeoRasterLayer”);
}
Please Reply As Soon As Possible
Hi Vivek,
Would you please add multiGeoRasterLayer into an existing LayerOverlay rather creating a new LayerOverlay by "LayerOverlay overlay = new LayerOverlay(); ", now the problem should be solved.
if you have any more question , please feel free to let us know.
Best Regards
Summer
Thanks Summer
Now Drawcore method is call but still images are not displayed on map.
I use following code:
Global.MvcGEO.MultiGeoRasterLayer.BuildReferenceFile(Server.MapPath("~\App_Data\referenceFile.txt"), Server.MapPath("~\App_Data"))
Dim multiGeoRasterLayer As Global.MvcGEO.MultiGeoRasterLayer = New Global.MvcGEO.MultiGeoRasterLayer(Server.MapPath("~\App_Data\referenceFile.txt"))
overlays.LayerOverlay("multiGeoRasterLayer").Layer("multiGeoRasterLayer", multiGeoRasterLayer).IsBaseOverlay(False).TileType(TileType.MultipleTile).IsVisible(True)
Hi Vivek,
Thanks for your further information, I tried to recreate the problem on our end with our data, but it didn’t show up, would you please upload your file for a further test?
Waiting for your further information.
Best Regards
Summer
Thanks Summer for reply
As you told me I am attaching my code with this reply
006_005_004_003_002_001_MyCode.txt (10.9 KB)
Hi Vivek,
Thanks for your code and what I actually mean is that we tested with our data, and it is ok, so would you please send us your data(not the code) for a further test?
Thanks,
Summer
Thanks Summer
I am attaching image files, which I want to load on map.
There are more than 50 images in my data, but I am attaching only 2 images with this reply.
My project is in MVC 3
003_002_001_Images.zip (1.56 MB)
Hi Vivek,
Thanks for your data, now it could be run on our end after some change in MultiGeoRasterLayer.cs(it is attached), following is a result image on our end.
Attached sample.txt is the test code on our end for your information.
Would you please try it again?
if you have any more question , please feel free to let us know.
Best Regards
Summer
004_003_002_001_SAMPLE.txt (932 Bytes)
MultiGeoRasterLayer.cs (8.53 KB)
Hi,
Thanks Summer.
Now images are displayed on a map, but still there is one problem that my image are not display at proper location.
As I am using Google map as a base overlay, and images coordinates are in different projection,
So how can I transform the coordinates to Google map.
I projection technique in DrawCore() method, but using that no any effect come.
So can you please tell me how can I convert coordinates, so images are display on appropriate position?
Thanks in advance…