Giter Club home page Giter Club logo

lookup's Introduction

Look Up

Code Climate Test Coverage

Look up at look-up-production.herokuapp.com

What is “LookUp”?

LookUp is a web-app that guides the user through a number of simple steps to survey a roof that they believe might be a good site for community solar power. Its overall aim is to engage and inspire a wider audience to consider setting up environmentally-friendly community energy projects that take some of the monopoly away from large energy companies.

How it works

The app collects the user's location using the google maps API, the direction that the roof is facing and the angle of the roof using your mobile’s in-built gyroscope and compass. It also collects other information such as the roof’s material and size, the potential shade that could fall on the roof during the day and a photograph of the site. At the end of the process the user is given an estimated amount of panels that can fit on the roof and the amount of power that these could generate based on the data collected.

How it was built

Built in Ruby with a Sinatra server and Postgres for the database. We used cucumber and capybara for our feature tests and RSpec for the unit tests.

Techs overview

Languages:

  • Ruby
  • Javascript

Frameworks:

  • Sinatra
  • Foundation

External libraries:

  • jQuery
  • Google maps API

Database:

  • PostrgeSQL

Test suites:

  • RSpec
  • Cucumber
  • Capybara

Deployed:

  • Heroku
  • AWS for saving images

Best code snippets

Retrieving geolocation in browser:

navigator.geolocation.getCurrentPosition(getPosition); 
var lat;
var longit;
var id = $('.page-wrap').data("roof-id");
function getPosition(position) {
  lat = position.coords.latitude;
  longit = position.coords.longitude;
}
$('#submit_button').click(function() {
  $.post('/roofs/' + id + '/geolocation',{ latitude: lat, longitude: longit });
});

Getting mobile phone accelerometer data:

if(window.DeviceOrientationEvent) {
  window.addEventListener('deviceorientation', function(event) {
  angle = Math.abs(Math.round(event.beta));
  if(angle !== null); 
  dataContainerOrientation.innerHTML = 'Roof angle: ' + angle + ' degrees';
  }, false);
  $('#capture').click(function(){
    $('#capture_hidden').attr('value', angle);
});

Checking if user running Safari, browser, as we encountered issues with complatibility with .click method:

if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0)
  {
    $("#takePictureField").click();
  }

Challenges

Used some external libraries, such as the map tool, which needed tweaking to make them work in our context. It wasn't possible to test the photo capture process or the touch screen map tool using cucumber/capybara which isn't ideal as they are quite complex steps. We made sure that we tested each on a number of different devices to ensure the feature's cross platform compatibility.

Team

Rich

Pavel

Attila

Shan

lookup's People

Contributors

ralake avatar pavlrd avatar tr1ckx avatar shanhasan avatar

Stargazers

Tim Scully avatar

Watchers

Tom Flannery avatar James Cloos avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.