際際滷

際際滷Share a Scribd company logo
Adding Where To
Your Ruby Apps




                     @bsao - Robson Junior
                  @rpepato - Roberto Pepato
Who are these guys ?
GIS?
Why GIS?
Why GIS?
http://video.esri.com/watch/41/network-analysis
Soft Part
reverse geocoding   reverse geocoding   reverse geocoding   reverse geocoding
    geocoding           geocoding
     routing             routing
How to work with
Geocoding in Ruby ?
see => http://railscasts.com/episodes/273-geocoder
Adding where to your ruby apps
Utilities
Mining
Security
Oil & Gas
More Applications ?
More Applications ?
Hard Part
Many Projections
Many Zones
A whole
A whole




Dif鍖cult Part
A whole




Dif鍖cult Part             Easy Part
A whole




Easy Part
Market
OpenSource


             Grass GIS
Adding where to your ruby apps
ESRI for Ruby ?
ESRI for Ruby ?




      #fail
ESRI for Ruby ?




                      #fail

Designed for C, C++, .Net, Java, Flex and Python*
ESRI guys told us:
Dont worry, we will provide you with a
              REST API




{ :get, :put, :post, :delete }
Seriously ? REST ?




      No semantics
      No resources
rgis - hard (boring?)
  part made easy
Adding where to your ruby apps
using System.Windows.Controls;


                                                 Project X,Y (ESRI .Net Silverlight API)
using System.Windows;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client;
using System.Collections.Generic;
using ESRI.ArcGIS.Client.Symbols;

namespace ArcGISSilverlightSDK
{
  public partial class Project : UserControl
  {
    GeometryService geometryService;
    GraphicsLayer graphicsLayer;

        public Project()
        {
          InitializeComponent();

            geometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.ProjectCompleted += geometryService_ProjectCompleted;
            geometryService.Failed += geometryService_Failed;

            graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
        }

        private void ProjectButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
           double x;
           double y;
           if (!double.TryParse(XTextBox.Text, out x) || !double.TryParse(YTextBox.Text, out y))
           {
               MessageBox.Show("Enter valid coordinate values.");
               return;
           }

            MapPoint inputMapPoint = new MapPoint(x, y, new SpatialReference(4326));

            geometryService.ProjectAsync(new List<Graphic>() { new Graphic() { Geometry = inputMapPoint } }, MyMap.SpatialReference, inputMapPoint);
        }

        void geometryService_ProjectCompleted(object sender, GraphicsEventArgs e)
        {
           Graphic resultGraphic = e.Results[0];

            if (resultGraphic.Geometry.Extent != null)
            {
                resultGraphic.Symbol = LayoutRoot.Resources["RoundMarkerSymbol"] as SimpleMarkerSymbol;

              MapPoint resultMapPoint = resultGraphic.Geometry as MapPoint;
              resultGraphic.Attributes.Add("Output_CoordinateX", resultMapPoint.X);
              resultGraphic.Attributes.Add("Output_CoordinateY", resultMapPoint.Y);

              MapPoint inputMapPoint = e.UserState as MapPoint;
              resultGraphic.Attributes.Add("Input_CoordinateX", inputMapPoint.X);
              resultGraphic.Attributes.Add("Input_CoordinateY", inputMapPoint.Y);

              graphicsLayer.Graphics.Add(resultGraphic);

               MyMap.PanTo(resultGraphic.Geometry);
            }
            else
            {
               MessageBox.Show("Invalid input coordinate, unable to project.");
            }

        }

        void geometryService_Failed(object sender, TaskFailedEventArgs e)
        {
           MessageBox.Show("Geometry Service error: " + e.Error);
        }
    }
}
Adding where to your ruby apps
Project X,Y (rgis)
point = RGis::Point.new(15,17)
new_point = point.project(:from => 4326, :to => 102100)
https://github.com/rgis/rgis
Questions?


https://github.com/rgis/rgis
Text
         @bsao
        @rpepato

Join us to make GIS easier:
   https://github.com/rgis

More Related Content

Adding where to your ruby apps

  • 1. Adding Where To Your Ruby Apps @bsao - Robson Junior @rpepato - Roberto Pepato
  • 2. Who are these guys ?
  • 8. reverse geocoding reverse geocoding reverse geocoding reverse geocoding geocoding geocoding routing routing
  • 9. How to work with Geocoding in Ruby ?
  • 26. OpenSource Grass GIS
  • 29. ESRI for Ruby ? #fail
  • 30. ESRI for Ruby ? #fail Designed for C, C++, .Net, Java, Flex and Python*
  • 31. ESRI guys told us: Dont worry, we will provide you with a REST API { :get, :put, :post, :delete }
  • 32. Seriously ? REST ? No semantics No resources
  • 33. rgis - hard (boring?) part made easy
  • 35. using System.Windows.Controls; Project X,Y (ESRI .Net Silverlight API) using System.Windows; using ESRI.ArcGIS.Client.Geometry; using ESRI.ArcGIS.Client.Tasks; using ESRI.ArcGIS.Client; using System.Collections.Generic; using ESRI.ArcGIS.Client.Symbols; namespace ArcGISSilverlightSDK { public partial class Project : UserControl { GeometryService geometryService; GraphicsLayer graphicsLayer; public Project() { InitializeComponent(); geometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.ProjectCompleted += geometryService_ProjectCompleted; geometryService.Failed += geometryService_Failed; graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; } private void ProjectButton_Click(object sender, System.Windows.RoutedEventArgs e) { double x; double y; if (!double.TryParse(XTextBox.Text, out x) || !double.TryParse(YTextBox.Text, out y)) { MessageBox.Show("Enter valid coordinate values."); return; } MapPoint inputMapPoint = new MapPoint(x, y, new SpatialReference(4326)); geometryService.ProjectAsync(new List<Graphic>() { new Graphic() { Geometry = inputMapPoint } }, MyMap.SpatialReference, inputMapPoint); } void geometryService_ProjectCompleted(object sender, GraphicsEventArgs e) { Graphic resultGraphic = e.Results[0]; if (resultGraphic.Geometry.Extent != null) { resultGraphic.Symbol = LayoutRoot.Resources["RoundMarkerSymbol"] as SimpleMarkerSymbol; MapPoint resultMapPoint = resultGraphic.Geometry as MapPoint; resultGraphic.Attributes.Add("Output_CoordinateX", resultMapPoint.X); resultGraphic.Attributes.Add("Output_CoordinateY", resultMapPoint.Y); MapPoint inputMapPoint = e.UserState as MapPoint; resultGraphic.Attributes.Add("Input_CoordinateX", inputMapPoint.X); resultGraphic.Attributes.Add("Input_CoordinateY", inputMapPoint.Y); graphicsLayer.Graphics.Add(resultGraphic); MyMap.PanTo(resultGraphic.Geometry); } else { MessageBox.Show("Invalid input coordinate, unable to project."); } } void geometryService_Failed(object sender, TaskFailedEventArgs e) { MessageBox.Show("Geometry Service error: " + e.Error); } } }
  • 37. Project X,Y (rgis) point = RGis::Point.new(15,17) new_point = point.project(:from => 4326, :to => 102100)
  • 40. Text @bsao @rpepato Join us to make GIS easier: https://github.com/rgis