Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into art/merge-develope…
Browse files Browse the repository at this point in the history
…-to-master-3
  • Loading branch information
REASY committed May 19, 2019
2 parents f23cdf5 + 464da63 commit bd8426b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/beam/sim/population/PopulationAttributes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ object AttributesOfIndividual {
}

case class HouseholdAttributes(
householdId: Int,
householdId: String,
householdIncome: Double,
householdSize: Int,
numCars: Int,
Expand All @@ -212,11 +212,11 @@ case class HouseholdAttributes(

object HouseholdAttributes {

val EMPTY = HouseholdAttributes(0, 0.0, 0, 0, 0)
val EMPTY = HouseholdAttributes("0", 0.0, 0, 0, 0)

def apply(household: Household, vehicles: Map[Id[BeamVehicle], BeamVehicle]): HouseholdAttributes = {
new HouseholdAttributes(
householdId = household.getId.toString.toInt,
householdId = household.getId.toString,
householdIncome = Option(household.getIncome)
.getOrElse(new IncomeImpl(0, IncomePeriod.year))
.getIncome,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HouseholdsXml2CsvConverter(householdAttributesXml: File) extends Xml2CsvFi

override val fields: Seq[String] = Seq("householdId", "incomeValue", "locationX", "locationY")

private type HouseholdId = Int
private type HouseholdId = String
private type HouseHoldIdToAttributes = Map[HouseholdId, HouseHoldAttributes]

private case class Household(householdId: HouseholdId, income: Income, locationX: Double, locationY: Double) {
Expand All @@ -30,8 +30,8 @@ class HouseholdsXml2CsvConverter(householdAttributesXml: File) extends Xml2CsvFi

private case class HouseHoldAttributes(
householdId: HouseholdId,
homeCoordX: Int,
homeCoordY: Int,
homeCoordX: Double,
homeCoordY: Double,
housingType: String
) {
override def toString: String = {
Expand All @@ -47,9 +47,9 @@ class HouseholdsXml2CsvConverter(householdAttributesXml: File) extends Xml2CsvFi
def fromSeq(name: String): String = attrs.find(_.attributes("name").text == name).get.text

HouseHoldAttributes(
householdId = node.attributes("id").toString.toInt,
homeCoordX = fromSeq("homecoordx").toInt,
homeCoordY = fromSeq("homecoordy").toInt,
householdId = node.attributes("id").toString,
homeCoordX = fromSeq("homecoordx").toDouble,
homeCoordY = fromSeq("homecoordy").toDouble,
housingType = fromSeq("housingtype")
)
}
Expand All @@ -64,7 +64,7 @@ class HouseholdsXml2CsvConverter(householdAttributesXml: File) extends Xml2CsvFi
}

private def toHousehold(node: Node, houseHoldIdToAttributes: HouseHoldIdToAttributes): Household = {
val id = node.attributes("id").toString.toInt
val id = node.attributes("id").toString
Household(
householdId = id,
income = toIncome((node \ "income").head),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object PlansXml2CsvConverter extends Xml2CsvFileConverter {
)

private case class PlanFlat(
personId: Int,
personId: String,
planId: Int,
planElementType: String,
activityIndex: Int,
Expand Down Expand Up @@ -61,7 +61,7 @@ object PlansXml2CsvConverter extends Xml2CsvFileConverter {
}

private def toPlans(personNode: Node): Seq[PlanFlat] = {
val personId = personNode.attributes("id").text.toInt
val personId = personNode.attributes("id").text
val planId = 1 // currently only one plan is supported

val seq = personNode \ "plan"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ class PopulationXml2CsvConverter(householdsXml: File, populationAttributesXml: F
override val fields: Seq[String] = Seq("personId", "age", "isFemale", "householdId", "houseHoldRank", "excludedModes")

private case class Person(
personId: Int,
personId: String,
age: Int,
isFemale: Boolean,
householdId: Int,
householdId: String,
householdRank: Int,
excludedModes: String
) {
override def toString: String =
Seq(personId, age, isFemale, householdId, householdRank, excludedModes).mkString(FieldSeparator)
}

private case class HouseholdMembers(houseHoldId: Int, memberIds: Seq[Int])
private case class HouseholdMembers(houseHoldId: String, memberIds: Seq[String])

type MemberId = Int
type HouseholdId = Int
type MemberId = String
type HouseholdId = String
type MemberToHousehold = Map[MemberId, HouseholdId]
private def readMemberToHousehold(): MemberToHousehold = {
val parser = ConstructingParser.fromFile(householdsXml, preserveWS = true)
Expand Down Expand Up @@ -53,26 +53,26 @@ class PopulationXml2CsvConverter(householdsXml: File, populationAttributesXml: F
def fromSeq(name: String): String = attrs.find(_.attributes("name").text == name).get.text

PersonAttributes(
objectId = node.attributes("id").toString.toInt,
objectId = node.attributes("id").toString,
excludedModes = fromSeq("excluded-modes"),
rank = fromSeq("rank").toInt
)
}

private case class PersonAttributes(objectId: Int, excludedModes: String, rank: Int) {
private case class PersonAttributes(objectId: String, excludedModes: String, rank: Int) {
override def toString: String = Seq(objectId, excludedModes, rank).mkString(FieldSeparator)
}

private def toHouseholdMembers(node: Node): HouseholdMembers = {
val householdId = node.attributes("id").text.toInt
val householdId = node.attributes("id").text
val memberIds = (node \ "members" \ "personId").map { node =>
node.attributes("refId").text.toInt
node.attributes("refId").text
}
HouseholdMembers(householdId, memberIds)
}

private def toPerson(node: Node, memberToHousehold: MemberToHousehold, member2Rank: MemberToRank): Person = {
val memberId = node.attributes("id").toString.toInt
val memberId = node.attributes("id").toString
Person(
personId = memberId,
age = 30,
Expand Down

0 comments on commit bd8426b

Please sign in to comment.