Skip to content

Commit

Permalink
Cleanup, rename AndroidPano -> WebVRPano, update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Oct 26, 2016
1 parent e8f68db commit 136f92c
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 73 deletions.
24 changes: 22 additions & 2 deletions README.md
@@ -1,5 +1,25 @@
# WebVRPano
Using WebVR to look at real estate

# Getting started
docker run -p 8080:5000 -d sboulema/androidpano:latest
# Running the WebVRPano server
docker run -p 8080:5000 -d sboulema/webvrpano:latest

# Using WebVRPano
How to use WebVRPano on your phone combined with a virtual reality solution

## Google Cardboard
1. Use Google Chrome and browse to the WebVRPano server
2. Insert TinyId
3. Place phone in Google Cardboard

## Samsung Gear VR (Google Chrome)
1. Use [Gear VR Cardboard](https://play.google.com/store/apps/details?id=com.bartslab.gearvrcardboard) to switch to developer mode and disable the Gear VR Service
2. Use Google Chrome and browse to the WebVRPano server
3. Insert TinyId
4. Place phone in Samsung Gear VR

## Samung Gear VR (Samsung Internet)
1. Place phone in Samsung Gear VR
2. Use Samsung Internet and browse to internet://webvr-enable
3. Browse to the WebVRPano server
4. Insert TinyId
2 changes: 1 addition & 1 deletion src/WebVRPano/Controllers/HomeController.cs
Expand Up @@ -23,7 +23,7 @@ public IActionResult Pano(string tinyId)
{
_panoService.LoadPano(tinyId);

ViewData["Pano"] = $"androidpano/{tinyId}/tour.xml";
ViewData["Pano"] = $"webvrpano/{tinyId}/tour.xml";

return View();
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebVRPano/Models/MediaItem.cs
@@ -1,4 +1,4 @@
namespace AndroidPano.Models
namespace WebVRPano.Models
{
public class MediaItem
{
Expand Down
2 changes: 1 addition & 1 deletion src/WebVRPano/Models/PanoModel.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;

namespace AndroidPano.Models
namespace WebVRPano.Models
{
public class PanoModel
{
Expand Down
2 changes: 1 addition & 1 deletion src/WebVRPano/Models/RootObject.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace AndroidPano.Models
namespace WebVRPano.Models
{
public class RootObject
{
Expand Down
2 changes: 1 addition & 1 deletion src/WebVRPano/Models/Sides.cs
@@ -1,4 +1,4 @@
namespace AndroidPano.Models
namespace WebVRPano.Models
{
public enum Sides
{
Expand Down
4 changes: 2 additions & 2 deletions src/WebVRPano/Services/IXMLservice.cs
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Xml.Linq;
using AndroidPano.Models;
using WebVRPano.Models;

namespace WebVRPano.Services
{
public interface IXMLService
public interface IXmlService
{
void Init();
void WriteToFile(string dir);
Expand Down
74 changes: 26 additions & 48 deletions src/WebVRPano/Services/PanoService.cs
Expand Up @@ -5,41 +5,40 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using AndroidPano.Models;
using Microsoft.AspNetCore.Hosting;
using Newtonsoft.Json;
using WebVRPano.Models;

namespace WebVRPano.Services
{
public class PanoService : IPanoService
{
private readonly IConfigurationService configurationService;
private readonly IXMLService xmlService;
private readonly IHostingEnvironment env;
private readonly IConfigurationService _configurationService;
private readonly IXmlService _xmlService;
private readonly IHostingEnvironment _env;

public PanoService(IConfigurationService configurationService, IXMLService xmlService, IHostingEnvironment env)
public PanoService(IConfigurationService configurationService, IXmlService xmlService, IHostingEnvironment env)
{
this.configurationService = configurationService;
this.xmlService = xmlService;
this.env = env;
_configurationService = configurationService;
_xmlService = xmlService;
_env = env;
}

public void LoadPano(string tinyId)
{
var panos = GetPanos(tinyId);
var objectDir = $@"{env.WebRootPath}/androidpano/{tinyId}/";
var objectDir = $@"{_env.WebRootPath}/webvrpano/{tinyId}/";
Directory.CreateDirectory(objectDir);

xmlService.Init();
_xmlService.Init();

ProcessPanos(panos, objectDir);
}

private PanoModel GetPanos(string tinyId)
{
string globalId = Descramble(tinyId);
var globalId = Descramble(tinyId);
if (string.IsNullOrEmpty(globalId) || globalId.Length < 7)
{
throw new Exception("Ongeldig tinyId");
Expand All @@ -52,7 +51,7 @@ private PanoModel GetPanos(string tinyId)

public List<RootObject> Get360Photos(string globalId, string soortAanbod)
{
var apiKey = configurationService.Get("ApiKey");
var apiKey = _configurationService.Get("ApiKey");

if (soortAanbod.Equals("nieuwbouw"))
{
Expand All @@ -63,11 +62,10 @@ public List<RootObject> Get360Photos(string globalId, string soortAanbod)

try
{
string response;
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
response = httpClient.GetStringAsync(requestUrl).Result;
var response = httpClient.GetStringAsync(requestUrl).Result;
return JsonConvert.DeserializeObject<List<RootObject>>(response);
}
}
Expand All @@ -81,11 +79,11 @@ public List<RootObject> Get360Photos(string globalId, string soortAanbod)

private string GetSoortAanbod(string globalId)
{
var apiKey = configurationService.Get("ApiKey");
var apiKey = _configurationService.Get("ApiKey");
var detailAlgemeenUrl = $"http://partnerapi.funda.nl/feeds/Aanbod.svc/detail/{apiKey}/algemeen/{globalId}";
HttpResponseMessage result;

using (HttpClient client = new HttpClient())
using (var client = new HttpClient())
{
result = client.GetAsync(detailAlgemeenUrl).Result;
}
Expand All @@ -96,20 +94,17 @@ private string GetSoortAanbod(string globalId)
var xdoc = XElement.Parse(xml);
return xdoc.Elements().FirstOrDefault(e => e.Name.LocalName.Equals("SoortAanbod")).Value;
}
else
{
Console.WriteLine(result.ReasonPhrase);
}


Console.WriteLine(result.ReasonPhrase);
return string.Empty;
}

private void ProcessPano(Pano pano, PanoModel panoModel, string objectDir)
private void ProcessPano(Pano pano, PanoModel panoModel)
{
HttpResponseMessage result;
string soortAanbod = panoModel.SoortAanbod;
var soortAanbod = panoModel.SoortAanbod;

using (HttpClient client = new HttpClient())
using (var client = new HttpClient())
{
result = client.GetAsync($"http://partnerapi.funda.nl/feeds/MijnFunda.svc/GetKrpanoXmlContent/?type={soortAanbod}&globalId={panoModel.GlobalId}&mediaGuid={pano.Id}").Result;
}
Expand All @@ -119,17 +114,17 @@ private void ProcessPano(Pano pano, PanoModel panoModel, string objectDir)
var xml = result.Content.ReadAsStringAsync().Result;
var xdoc = XDocument.Parse(Sanitize(xml));
var images = xdoc.Root.Descendants("tablet").Descendants();
xmlService.AddScene(pano, GetHotspots(xdoc, panoModel), images.First().FirstAttribute.Value);
_xmlService.AddScene(pano, GetHotspots(xdoc, panoModel), images.First().FirstAttribute.Value);
}
else
{
Console.WriteLine(result.ReasonPhrase);
}
}

private string Sanitize(string xml)
private static string Sanitize(string xml)
{
string result = xml;
var result = xml;

result = result.Replace("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">", string.Empty);
result = result.Replace("&lt;", "<");
Expand All @@ -143,12 +138,12 @@ private void ProcessPanos(PanoModel panos, string objectDir)
{
foreach (var pano in panos.Panos)
{
ProcessPano(pano, panos, objectDir);
ProcessPano(pano, panos);
}
xmlService.WriteToFile(objectDir);
_xmlService.WriteToFile(objectDir);
}

private IEnumerable<XElement> GetHotspots(XDocument xdoc, PanoModel panos)
private static IEnumerable<XElement> GetHotspots(XDocument xdoc, PanoModel panos)
{
var hotspots = xdoc.Root.Descendants("hotspot");
foreach (var hotspot in hotspots)
Expand All @@ -165,23 +160,6 @@ private IEnumerable<XElement> GetHotspots(XDocument xdoc, PanoModel panos)
return hotspots;
}

private async Task DownloadFileAsync(string url, string filename)
{
try
{
using (HttpClient httpClient = new HttpClient())
{
var contentStream = httpClient.GetStreamAsync(url).Result;
var stream = new FileStream(filename, FileMode.Create);
await contentStream.CopyToAsync(stream);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}

private static string Descramble(string input)
{
try
Expand Down
4 changes: 2 additions & 2 deletions src/WebVRPano/Services/XMLService.cs
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;
using AndroidPano.Models;
using WebVRPano.Models;

namespace WebVRPano.Services
{
public class XmlService : IXMLService
public class XmlService : IXmlService
{
XElement _tourXml;

Expand Down
2 changes: 1 addition & 1 deletion src/WebVRPano/Startup.cs
Expand Up @@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddTransient<IConfigurationService>(r => new ConfigurationService(Configuration));
services.AddTransient<IPanoService, PanoService>();
services.AddTransient<IXMLService, XmlService>();
services.AddTransient<IXmlService, XmlService>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
2 changes: 0 additions & 2 deletions src/WebVRPano/Views/_ViewImports.cshtml

This file was deleted.

2 changes: 0 additions & 2 deletions src/WebVRPano/wwwroot/_references.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/WebVRPano/wwwroot/web.config

This file was deleted.

0 comments on commit 136f92c

Please sign in to comment.