Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions schools/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ end
gem 'geocoder'

gem 'gmaps4rails'

gem 'arcserver.rb', '~> 0.1.5'
15 changes: 15 additions & 0 deletions schools/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ GEM
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arcserver.rb (0.1.5)
activesupport
httparty
httpclient
json
nokogiri
rufus-scheduler
arel (7.1.4)
builder (3.2.3)
coffee-rails (4.2.1)
Expand All @@ -57,6 +64,9 @@ GEM
activesupport (>= 4.1.0)
gmaps4rails (2.1.2)
hashie (3.4.6)
httparty (0.14.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (0.8.0)
jbuilder (2.6.1)
activesupport (>= 3.0.0, < 5.1)
Expand All @@ -65,6 +75,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.0.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
Expand All @@ -76,6 +87,7 @@ GEM
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (1.2.1)
nokogiri (1.7.0.1-x64-mingw32)
Expand Down Expand Up @@ -114,6 +126,8 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rufus-scheduler (3.3.4)
tzinfo
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand Down Expand Up @@ -160,6 +174,7 @@ PLATFORMS
x64-mingw32

DEPENDENCIES
arcserver.rb (~> 0.1.5)
byebug
coffee-rails (~> 4.2)
geocoder
Expand Down
41 changes: 33 additions & 8 deletions schools/app/controllers/schools_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require 'geocoder'
require 'arcserver'

class SchoolsController < ApplicationController
def index
@schools = School.for
#@schools = School.for
end

def about
Expand All @@ -15,13 +16,37 @@ def navigate_school_choice
end

def find_feeder_pattern
@address = params[:address]
@coordinates = Geocoder.coordinates(params[:address])
@locations = Array.new(1, Location.new(@address))
@hash = Gmaps4rails.build_markers(@locations) do |location, marker|
marker.lat location.latitude
marker.lng location.longitude
end
@address = params[:address]
@coordinates = Geocoder.coordinates(params[:address])
@locations = Array.new(1, Location.new(@address))
if @coordinates != nil
map_server = ArcServer::MapServer.new('https://firstmap.delaware.gov/arcgis/rest/services/Boundaries/DE_SchoolDistricts/MapServer')
point = ArcServer::Geometry::Point.build({ x: @coordinates[1], y: @coordinates[0] }, "esriGeometryPoint")
@feature_set = map_server.query(0,
{
geometry: point,
spatialRelationship: "esriSpatialRelContains",
inSR: "4326",
outSR: "4326",
outFields: "NAME, DIST_ID",
returnGeometry: "false"
})
feature = @feature_set.features[0]
if feature != nil
@attributes = feature.attributes
@name = @attributes["NAME"]
@dist_id = @attributes["DIST_ID"].to_s
schools_array = School.by_district(@dist_id)
schools_array.each do |school|
@locations << School.new(school).location
end
end
end

@hash = Gmaps4rails.build_markers(@locations) do |location, marker|
marker.lat location.latitude
marker.lng location.longitude
end
end

def find_school
Expand Down
21 changes: 19 additions & 2 deletions schools/app/models/school.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
require 'soda/client'

class School


attr_accessor :location

def self.for
client = SODA::Client.new({:domain => "data.delaware.gov"})
client = SODA::Client.new({:domain => "data.delaware.gov", :app_token => 'ChbkYOVvWw1Is07SIJatQvc3J'})
client.get("https://data.delaware.gov/resource/f6a3-crpj.json", {})
end

def self.by_district(district_code)
client = SODA::Client.new({:domain => "data.delaware.gov", :app_token => 'ChbkYOVvWw1Is07SIJatQvc3J'})
client.get("https://data.delaware.gov/resource/f6a3-crpj.json", {districtcode: district_code })
end

def initialize(school)
if school["street2"] == "--"
street = school["street1"]
else
street = school["street2"]
end
address = street << " " << school["city"] << " " << school["state"] << " " << school["zip"]
@location = Location.new(address)
end
end
9 changes: 9 additions & 0 deletions schools/app/models/school_district_boundary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'arcserver'
require 'soda/client'

class SchoolDistrictBoundary
def self.for
client = SODA::Client.new({:domain => "data.delaware.gov"})
client.get("https://data.delaware.gov/resource/krpv-uu7g.json", {})
end
end
3 changes: 2 additions & 1 deletion schools/app/views/schools/find_feeder_pattern.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<%= submit_tag("Search") %>
<% end %>
<p><%= content_tag(:span, "#{@address}") %></p>

<p><%= content_tag(:span, "District Name: " + "#{@name}") %></p>
<p><%= content_tag(:span, "District ID : " + "#{@dist_id}") %></p>
<div style='width: 800px;'>
<div id="map" style='width: 800px; height: 400px;'></div>
</div>
Expand Down