-----------------------------------

Acquista i software ArcGIS tramite Studio A&T srl, rivenditore autorizzato dei prodotti Esri.

I migliori software GIS, il miglior supporto tecnico!

I migliori software GIS, il miglior supporto tecnico!
Azienda operante nel settore GIS dal 2001, specializzata nell’utilizzo della tecnologia ArcGIS e aderente ai programmi Esri Italia Business Network ed Esri Partner Network

-----------------------------------



sabato 24 ottobre 2009

ArcGIS Javascript API 1.5

E' disponibile la nuova versione di API per ARCGIS javascript.
Mentre per quel che riguarda le estensioni per Google Maps API e Microsoft Virtual Earth non ci sono state modifiche.
In sintesi le novità sono:
- supporto per Firefox 3.5
- supporto per Dojo 1.3.2
- possibilità di modificare il tipo di cursor ( nello specifico utilizzando Map.setMapCursor() )
- possibilità di accedere ai javascript API in modalità HTTPS
- correzione di diversi bugs per migliorare le prestazioni e la stabilità degli ArcGIS JavaScript API

Per dettagli segui il link

martedì 13 ottobre 2009

Geocoding & StreetView Google per ESRI API Silverlight

Pagine aspx dell'applicazione web

<%@ Page="" Language="C#" AutoEventWireup="true" %>
<%@ Register="" Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=YourKey" type="text/javascript"></script>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="http://ui.jquery.com/latest/ui/effects.core.js" type="text/javascript"></script>
<script src="http://ui.jquery.com/latest/ui/effects.explode.js" type="text/javascript"></script>
<script src="http://ui.jquery.com/latest/ui/ui.core.js" type="text/javascript"></script>
<script src="http://ui.jquery.com/latest/ui/ui.draggable.js" type="text/javascript"></script>
<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head runat="server">
<title>Silverlight Google Geocode/StreetView</title>
<script type="text/javascript">
$(document).ready(function() {
$('#txtAddress').keypress(function(e) {
if (e.which == 13) {
$('#btnFindAddress').click();
e.preventDefault();
}
});
});
function runEffect(x,y,divID) {
//run the effect
$("#" + divID).css({ left: x, top: y });
$("#" + divID).effect('bounce');
//set draggable
$("#" + divID).draggable({ cursor: 'crosshair'});
$("#" + divID).draggable('disable');
};
var geocoder;
function FindAddress(address) {
geocoder = new GClientGeocoder();
geocoder.getLocations(address, addAddressToMap);
}
function addAddressToMap(response) {
if (!response response.Status.code != 200) {
alert("No Address found");
} else {
place = response.Placemark[0];
var lon = place.Point.coordinates[0];
var lat = place.Point.coordinates[1];
var address = place.address;
slControl.Content.slApplication.FindIndirizzo(lon, lat, address);
}
}
function streetView(lat, lon, x, y, divID) {
//alert("Message received from Silverlight:" + divID);
var latlng = new GLatLng(lat, lon);
var svp = new GStreetviewClient();
svp.getNearestPanoramaLatLng(latlng,
function(newPoint) {
if (newPoint == null) {
alert("Street View Not Available For This Location");
return;
}
var divMain = document.createElement('div');
divMain.setAttribute("id", divID + "_Contain");
divMain.setAttribute("style", "position:absolute; z-index:1000; height: 325px; width: 300px;background-color:#888888");
var btnDraggable = document.createElement('input');
btnDraggable.setAttribute("id", divID + "_Move");
btnDraggable.setAttribute("type", "button");
btnDraggable.setAttribute("style", "position:relative;z-index:1000;height: 25px; width: 60px;left:5px;top:5px");
btnDraggable.setAttribute("value", "unlock");
btnDraggable.setAttribute("onclick", "var a = $get('" + divID + "_Move');var b = $('#" + divID + "_Contain');if (a.value =='unlock') {a.value = 'lock'; b.draggable('enable');}else{a.value = 'unlock';b.draggable('disable');}");
divMain.appendChild(btnDraggable);
var btnClose = document.createElement('input');
btnClose.setAttribute("id", divID + "_Close");
btnClose.setAttribute("type", "button");
btnClose.setAttribute("style", "position:relative;z-index:1000;height: 25px; width: 60px;left:180px;top:5px");
btnClose.setAttribute("value", "close");
btnClose.setAttribute("onclick", "var a = $get('" + divID + "_Contain');a.style.display='none';");
divMain.appendChild(btnClose);
var divSV = document.createElement('div');
divSV.setAttribute("id", divID);
divSV.setAttribute("style", "position:relative;z-index:1000;height: 290px; width: 290px;left:5px;top:5px");
divMain.appendChild(divSV);
document.forms[0].insertBefore(divMain, $get("controlSL"));
panoramaOptions = { latlng: newPoint };
svp = new GStreetviewPanorama(divSV);
GEvent.addListener(svp, "error", StreetViewError);
var myPov = { yaw: 176.03773913343627, pitch: -0.13590989423507835 };
svp.setLocationAndPOV(latlng, myPov);
runEffect(x, y, divID + "_Contain");
});
}
function StreetViewError(errorCode) {
if (errorCode == 603) {
alert("Error: Flash doesn't appear to be supported by your browser");
return;
}
if (errorCode == 600) {
alert("Street View Not Available For This Location");
return;
}
}
var slControl = null;
function pluginLoaded(sender){
slControl = sender.get_element();
};
</script>
</head>
<body style="height:100%;margin:0;">
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id ="controlSL" style="height:100%;">
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/saGoogleGeocode.xap" Windowless ="true" OnPluginLoaded="pluginLoaded" MinimumVersion="2.0.31005.0" Width="100%" Height="97%" />
<input id="txtAddress" type="text" />
<input id="btnFindAddress" type="button" value="Find address (Google)" onclick="FindAddress($get('txtAddress').value);" />
</div>
</form>
</body>
</html>


Page.xaml


using System;
using System.Windows.Browser;
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
//Domenico Ciavarella www.studioat.it
namespace saGoogleGeocode
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
[ScriptableMember()]
public void FindIndirizzo(double lon, double lat, string address)
{
Graphic graphic = new Graphic();
graphic.Symbol = StrobeMarkerSymbol;
graphic.Attributes.Add("Address", address);
MapPoint pt = new MapPoint(lon, lat,new SpatialReference(4326));
graphic.Geometry = pt;
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
graphicsLayer.Graphics.Add(graphic);
MyMap.ZoomTo(pt.Envelope(0.005));
//if you project point
//GeometryService geometryService = new GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
//geometryService.ProjectCompleted += GeometryService_ProjectCompleted;
//graphic.Geometry = new MapPoint(lon, lat, new SpatialReference(4326));
//IList<Graphic> graphics = new List<Graphic>() { graphic };
//geometryService.ProjectAsync(graphics, new SpatialReference(3003)); //<---your wkid
}
private void MyMap_MouseClick(object sender, Map.MouseEventArgs e)
{
MapPoint p = e.MapPoint;
string divId = Guid.NewGuid().ToString();
HtmlPage.Window.Invoke("streetView", p.Y, p.X, e.ScreenPoint.X, e.ScreenPoint.Y,divId);
}
}
public static class Utility
{
public static Envelope Envelope(this MapPoint pt, double expand)
{
return new Envelope(pt.X - expand, pt.Y - expand, pt.X + expand, pt.Y + expand);
}
}
}


Scarica qui la soluzione

sabato 3 ottobre 2009

Store IGeometry in SQL server 2008

Problema: supponiamo di avere un web service che crea IGeometry utilizzando ArcGIS Server e di voler esporre il dato geometrico per SQL Server 2008 (Express).


Soluzione: per ottimizzare il passaggio dei dati dal web service al client conviene passarli in wkb (well-known binary). Per questa operazione ci viene incontro un metodo degli ArcObjects: CreateWkbVariantFromGeometry.


Con il seguente codice convertiamo una IGeometry nella rappresentazione wkb.


IPolygon polygon = GetIGeometry();


IGeometryFactory3 geometryFactory = (IGeometryFactory3)serverContext.CreateObject("esriGeometry.GeometryEnvironment");


byte[] polygonWKB = geometryFactory.CreateWkbVariantFromGeometry(polygon) as byte[];



Lato client: creiamo un SqlGeometry con il metodo SQL server 2008 STGeomFromWKB e prima di memorizzare la geometria la validiamo con il metodo MakeValidGeographyFromGeometry della libreria SQL Server Spatial Tools


System.Data.SqlTypes.SqlBytes polygonWKB = new System.Data.SqlTypes.SqlBytes(PolygonWKB);


SqlGeometry sqlGeometry = SqlGeometry.STGeomFromWKB(polygonWKB, 4326);



SqlGeography sqlGeography = Functions.MakeValidGeographyFromGeometry(sqlGeometry);



using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnectionString"].ConnectionString))


{


conn.Open();


string sqlCommandText = "insert into [YourTable]([Punto],[Poligono]) Values(@pPunto,@pPoligono)";



SqlGeography punto = SqlGeography.Point(lat, lon, 4326);


using (SqlCommand sqlCommand = new SqlCommand(sqlCommandText, conn))


{


sqlCommand.CommandType = CommandType.Text;


sqlCommand.Parameters.Add(new SqlParameter("@pPunto", punto) { UdtTypeName = "Geography" });


sqlCommand.Parameters.Add(new SqlParameter("@pPoligono", sqlGeometry) { UdtTypeName = "Geography" });


sqlCommand.ExecuteNonQuery();



}



}