Skip to content

Commit

Permalink
Inital Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Jul 9, 2016
0 parents commit d1dc811
Show file tree
Hide file tree
Showing 15 changed files with 467 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/data/codepointopen/*.csv
.DS_Store
/vendor
28 changes: 28 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2014-2016, JMB Technology Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

Neither the name of JMB Technology Ltd nor any of their products (including
but not limited to OpenACalendar, HasACalendar and OpenTechCalendar) nor the
names of any contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OSData

An PHP Library for working with Ordnance Survey Open Data

27 changes: 27 additions & 0 deletions bin/CodePointOpen/getPostCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src-bin'.DIRECTORY_SEPARATOR.'bootstrap.php';


/**
*
* @link https://github.com/JMB-Technology-Limited/OSData
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/
*/

$dir = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'codepointopen'.DIRECTORY_SEPARATOR;

$dataAdaptor = new \JMBTechnologyLimited\OSData\CodePointOpen\FileDataAdaptor($dir);

$service = new \JMBTechnologyLimited\OSData\CodePointOpen\CodePointOpenService($dataAdaptor);

$postCode = $service->getPostcode($argv[1]);

if ($postCode) {
print "Lat,Lng: ". $postCode->getLat().",".$postCode->getLng()."\n";
} else {
print "Not Found\n";
}


26 changes: 26 additions & 0 deletions bin/CodePointOpen/loadDataToFileDataAdaptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src-bin'.DIRECTORY_SEPARATOR.'bootstrap.php';


/**
*
* @link https://github.com/JMB-Technology-Limited/OSData
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/
*/


$inDir = $argv[1];

$outDir = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'codepointopen'.DIRECTORY_SEPARATOR;

$dataAdaptor = new \JMBTechnologyLimited\OSData\CodePointOpen\FileDataAdaptor($outDir);

$service = new \JMBTechnologyLimited\OSData\CodePointOpen\CodePointOpenService($dataAdaptor);

$service->loadData($inDir);

print "Done";


20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "jmbtechnologylimited/osdata",
"type": "library",
"description": "for working with Ordnance Survey Open Data",
"keywords": [],
"homepage": "https://github.com/JMB-Technology-Limited/OSData",
"license": "BSD",
"authors": [ ],
"require": {
"php": ">=5.3.0",
"jmbtechnologylimited/osmaths": "1.0.*"
},
"autoload": {
"psr-0": {
"JMBTechnologyLimited": "src"
}
},
"require-dev": {
}
}
52 changes: 52 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
20 changes: 20 additions & 0 deletions src-bin/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';

/**
*
* @link https://github.com/JMB-Technology-Limited/OSData
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/
*/

function autoload($class) {
$f = __DIR__. DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.
'src'.DIRECTORY_SEPARATOR.str_replace("\\", DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($f)) {
require_once $f;
return;
}
}
spl_autoload_register('autoload');
16 changes: 16 additions & 0 deletions src/JMBTechnologyLimited/OSData/BaseDataAdaptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace JMBTechnologyLimited\OSData;

/**
*
* @link https://github.com/JMB-Technology-Limited/OSData
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/
*/

abstract class BaseDataAdaptor {


}

29 changes: 29 additions & 0 deletions src/JMBTechnologyLimited/OSData/BaseDataService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace JMBTechnologyLimited\OSData;


/**
*
* @link https://github.com/JMB-Technology-Limited/OSData
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/
*/

abstract class BaseDataService {




/**
* @return boolean Was this successful?
*/
abstract public function openConnection();

abstract public function closeConnection();

abstract public function loadData($sourceDir);



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php


namespace JMBTechnologyLimited\OSData\CodePointOpen;


use JMBTechnologyLimited\OSData\BaseDataService;

/**
*
* @link https://github.com/JMB-Technology-Limited/OSData
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/
*/

class CodePointOpenService extends BaseDataService {


/** @var InterfaceDataAdaptor */
protected $dataAdaptor;

/**
* CodePointOpenService constructor.
*
*@param InterfaceDataAdaptor $dataAdaptor
*/
public function __construct( InterfaceDataAdaptor $dataAdaptor)
{
$this->dataAdaptor = $dataAdaptor;
}


/**
* @return boolean Was this successful?
*/
public function openConnection()
{

}

public function closeConnection()
{

}

public function loadData($sourceDir)
{
$this->dataAdaptor->loadData($sourceDir);
}

/** @return PostCodeData */
public function getPostcode($postcode)
{
return $this->dataAdaptor->getPostcode($postcode);
}

}

Loading

0 comments on commit d1dc811

Please sign in to comment.