X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fdeploy_zone.pm;fp=FS%2FFS%2Fdeploy_zone.pm;h=16ba5ddf37dfc654216e7d53286a7c7b6fee9cef;hp=723b491c852ef47e7f75ec3e4a1cc368cf80684c;hb=b3b6d0750030d08032756ad4a6969e193a65a928;hpb=86fb4649060ed26420bb1931481885064e76abc5 diff --git a/FS/FS/deploy_zone.pm b/FS/FS/deploy_zone.pm index 723b491c8..16ba5ddf3 100644 --- a/FS/FS/deploy_zone.pm +++ b/FS/FS/deploy_zone.pm @@ -10,9 +10,14 @@ use Cpanel::JSON::XS; use LWP::UserAgent; use HTTP::Request::Common; +use Geo::JSON::Polygon; +use Geo::JSON::Feature; + # update this in 2020, along with the URL for the TIGERweb service our $CENSUS_YEAR = 2010; +our $tech_label = FS::part_pkg_fcc_option->technology_labels; + =head1 NAME FS::deploy_zone - Object methods for deploy_zone records @@ -275,6 +280,27 @@ sub deploy_zone_vertex { }); } +=item shapefile_add SHAPEFILE + +Adds this deployment zone to the supplied Geo::Shapelib shapefile. + +=cut + +sub shapefile_add { + my( $self, $shapefile ) = @_; + + my @coordinates = map { [ $_->longitude, $_->latitude, 0, 0 ] } + $self->deploy_zone_vertex; + push @coordinates, $coordinates[0]; + + push @{$shapefile->{Shapes}}, { 'Vertices' => \@coordinates }; + push @{$shapefile->{ShapeRecords}}, [ $tech_label->{$self->technology}, + $self->adv_speed_down, + $self->adv_speed_up, + ]; + ''; +} + =item vertices_json Returns the vertex list for this zone, as a JSON string of @@ -289,6 +315,51 @@ sub vertices_json { encode_json(\@vertices); } +=item geo_json_feature + +Returns this zone as a Geo::JSON::Feature object + +=cut + +sub geo_json_feature { + my $self = shift; + + my @coordinates = map { [ $_->longitude, $_->latitude ] } + $self->deploy_zone_vertex; + push @coordinates, $coordinates[0]; + + Geo::JSON::Feature->new({ + geometry => Geo::JSON::Polygon->new({ coordinates => [ \@coordinates ] }), + properties => { 'Technology' => $tech_label->{$self->technology}, + 'Down' => $self->adv_speed_down, + 'Up' => $self->adv_speed_up, + }, + }) +} + +=item kml_add + +Adds this deployment zone to the supplied Geo::GoogleEarth::Pluggable object. + +=cut + +sub kml_polygon { + my( $self, $kml ) = @_; + + my $name = $self->description. ' ('. $self->adv_speed_down. '/'. + $self->adv_speed_up. ')'; + + $kml->Polygon( 'name' => $name, + 'coordinates' => [ [ #outerBoundary + map { [ $_->longitude, $_->latitude, 0 ] } + $self->deploy_zone_vertex + ], + #[ #innerBoundary + #] + ] + ); +} + =head2 SUBROUTINES =over 4